Friday, 11 October 2013

Sum one by one ,Second highest salary

select a.Id, a.Name, sum(b.Name) as sum from Table_5 a cross join Table_5 b where b.Id <= a.Id group by a.Id, a.Name



Select * From Table_5 T1 Where 3=(Select Count(Distinct(t2.salary)) From Table_5 T2 Where T2.salary > T1.salary)



select min(name) from Table_5 where name in (select   distinct top 5 name  from Table_5 order by name desc)

No comments:

Post a Comment