有一个product表:

查询每一列之和,按照category
select [category], sum([quantity]) Total from [testSql].[dbo].[product] group by [category]

查询最大的category:
select [category], oneTotal from (select [category], sum([quantity]) oneTotal from [testSql].[dbo].[product] group by [category]) T
where oneTotal = (select max(oneTotal) from
(select [category], sum([quantity]) oneTotal from [testSql].[dbo].[product] group by [category]) T)

501

被折叠的 条评论
为什么被折叠?



