15,881,709 members
See more:
1 IMRAN 17 30000
3 KAMRAAN 17 32000
4 ASIF 19 40000
5 TOFEEQ 18 33000
Posted
Updated 11-Nov-15 16:41pm
v4
Dave Kreskowiak 11-Nov-15 13:40pm
And the question would be .......??

You really don't expect us to do your homework for you, right?

## Solution 1

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

## Solution 2

ROW_NUMBER[^] is that what you're looking for.

SQL
```SELECT RowNo, T_ID, T_NAME, BPS_GRADE, SALARY
FROM (
SELECT T_ID, T_NAME, BPS_GRADE, SALARY, ROW_NUMBER OVER(ORDER BY SALARY DESC) AS RowNo
FROM YourTableName
) AS T
WHERE RowNo IN (2,3)```

See the other ranking functions[^] too.

v2

## Solution 3

Try Below Example :-

---FIND SECONDMAXSAL SALARY

SQL
`SELECT MAX(ESAL)AS SECONDMAXSAL FROM EMP1 WHERE ESAL NOT IN(SELECT MAX(ESAL) FROM EMP1)`

--FIND THIRDMAXSAL SALARY

SQL
`SELECT MIN(ESAL)AS THIRDMAXSAL FROM EMP1 WHERE ESAL IN(SELECT TOP 3 (ESAL) FROM EMP1 ORDER BY ESAL DESC)`