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
10/07/2014
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment