Sunday, August 3, 2014

Second highest salary------



Second highest salary------
SELECT*
FROM EmployeeDetails e1
WHERE (1)=(
SELECTCOUNT(DISTINCT(e2.Salary))
FROM EmployeeDetails e2
WHERE e2.Salary > e1.Salary)

selecttop 1 salary from
selectdistincttop 2 salary from EMPLOYEE orderby salary desc)
as salary orderby salary asc