Create table #emp(empid int, deptno int, sal int)
insert into #emp values(1001,10,12345)
insert into #emp values(1002,10,22445)
insert into #emp values(1003,10,33345)
insert into #emp values(1004,20,89765)
insert into #emp values(1005,20,34562)
insert into #emp values(1006,20,11234)
insert into #emp values(1007,20,32145)
insert into #emp values(1008,30,23145)
insert into #emp values(1009,30,22134)
insert into #emp values(10010,30,45326)
insert into #emp values(10011,40,34561)
insert into #emp values(10012,40,20000)
o/p expected:
----------------
Deptno sum(sal) salary%
-------------------------------------
10 68135 17
20 167706 44
30 90605 23
40 54561 14