SQL query to find the 3rd oldest employee

SQL Query to Find the 3rd Oldest Employee

Solution #1: find employee

1 SELECT * FROM
2 (
3 SELECT TOP 3 ROW_NUMBER() OVER(ORDER BY DateOfBirth) AS row,* FROM Employee
4 ) Emp
5 WHERE row=3Code language: PHP (php)

Solution 2:

1 SELECT TOP 1 * FROM
2 (
3 SELECT TOP 3 * FROM Employee ORDER BY DateOfBirth
4 ) Emp 
5 ORDER BY DateOfBirth DESC

To learn more about SQL Query, check out this blog link.

Feel free to leave any comments for clarification, changes, or improvements. Also, you can contact with iXora Solution expert teams for any consultation or coordination from here.

Add a Comment

Your email address will not be published. Required fields are marked *