iXora Custom Software Development Blog

Read | Practice | Advance

SQL query to find the 3rd oldest employee

Posted by on in Blog
  • Font size: Larger Smaller
  • Hits: 3194
  • 0 Comments

Solution #1:

SELECT * FROM
(
SELECT TOP 3 ROW_NUMBER() OVER(ORDER BY DateOfBirth) AS row,* FROM Employee
) Emp
WHERE row=3

Solution #2:

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

If any more solutions please comment.

Rate this blog entry:
1

Comments

  • No comments made yet. Be the first to submit a comment

Leave your comment

Guest
Guest Wednesday, 21 October 2020