--Returns name and salary of employee assuming EMPLOYEE and SALARY are different tables with --column ID connecting both SELECT NAME,SALARY FROM EMPLOYEE INNER JOIN SALARY ON EMPLOYEE.ID=SALARY.ID WHERE SALARY IN( --following query returns required salary (Second largest in example) SELECT MAX(SALARY) FROM SALARY WHERE SALARY NOT IN ( --follwing query returns top x(1 in example) salaries --replace x to 0,1,... to get highest, second highest,... SELECT TOP 1 SALARY FROM SALARY ORDER BY salary DESC ) ) |
SQL Query to find THIRD highest salaried employee:-
SELECT name, |