Query to find second and third highest value

Query to find second and third highest value
SQL query to find second and third highest value in empid column
Replace empid column name with salary to apply the logic on salary column

SELECT *
  FROM (SELECT ROWNUM row_num, b.*
          FROM (  SELECT e.*
                    FROM emp e
                ORDER BY empid DESC) b)
 WHERE row_num IN (2, 3)
Related posts: Upload your own post and refer it anywhere anytime:

Leave a Reply