Navaneeth Krishnan
Find the second maximum record in a SQL Table/ Temp Table?
By Navaneeth Krishnan in .NET on Aug 24 2020
  • Archana Parmar
    Sep, 2020 24

    SELECT MAX (Income)
    FROM Employee
    WHERE Salary NOT IN (SELECT Max (Income)
    FROM Employee);

    • 2
  • Shradhanjali Mohapatra
    Feb, 2021 19

    ;WITH CTE
    AS
    (
    SELECT ROW_NUMBER() OVER(ORDER BY Income DESC) ROW_NUM, Income
    FROM Employee
    )

    SELECT Income FROM CTE WHERE ROW_NUM = 2

    • 1
  • Santhosh Kumar
    Sep, 2020 9

    select * from (select sal, dense_rank()over(order by sal desc)rank from tempemp) Where rank=2;. -- you can change the rank value -- example if you need 5th max record then rank=5

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS