34,590
社区成员
发帖
与我相关
我的任务
分享
select 货号,sum(数量)总量,max(ID),max(样式),max(价格)
from 表 group by 货号
select * from (SELECT [货号]
,[数量]
,SUM(数量)over(partition by 货号) '总量'
FROM [Test].[dbo].[T1]) A where not exists(select * from T1 B where B.货号=A.货号 and B.数量>A.数量)
group by 货号
select 货号,sum(数量),max(ID),max(样式),max(价格) from 表