Posts

Showing posts from April, 2010

Select all rows from Employee table for employees having second highest salary

DECLARE @Num INT SET @Num = 2 --// Set it accordingly. If second highest salary then 2, if third highest then 3. --//This should be greater than 0 SELECT A.* FROM Employee A WHERE @Num - 1 = ( SELECT COUNT(DISTINCT B.Salary) FROM Employee B WHERE B.Salary > A.Salary )

Make Money from Surveys