27,579
社区成员
发帖
与我相关
我的任务
分享
select hr_no ,SUM(total) as alltotal from A
group by hr_no
if object_id('tb') is not null
drop table tb
go
create table tb([hr_no] varchar(10),[total] float)
insert tb select 1,20
insert tb select 1,30
insert tb select 1,5
insert tb select 2,40
insert tb select 2,50
go
select hr_no,sum(total) total from tb group by hr_no
/*
hr_no total
---------- ----------------------
1 55
2 90
*/
select hr_no,sum(total) as alltotal
from tb
group by hr_no
select hr_no,sum(total) total from tb group by hr_no