Breaking News
Loading...
10/07/2014

test

DECLARE @tblEmployee AS table (
 id int primary key identity (1, 1),
 salaryLastYear int,
 salaryCurrentYear int
)
insert into @tblEmployee
values (10, 20), (20, 30), (30, 40)

set statistics io on;

select id,
 sum(salaryLastYear) as [TotalSalaryLastYear],
 sum(salaryCurrentYear) as [TotalSalaryCurrentYear],
 CASE WHEN id IS NULL THEN 1 ELSE 0 END AS flag
from @tblEmployee
GROUP BY id
WITH ROLLUP

0 comments:

Post a Comment

 
Toggle Footer