How to get second largest or third largest entry from a table

前端 未结 12 2492
说谎
说谎 2020-12-01 08:42

Can anyone please tell me how to find out the N th largest entry from a table in Oracle?

Like for largest we can use MAX(column_name) i

12条回答
  •  一生所求
    2020-12-01 09:16

    I think the below query will work to find the second highest record with NOT IN.

    SELECT MAX( userId )
    FROM table 
    WHERE userId NOT IN ( 
                          SELECT MAX( userId )
                          FROM table
                        ); 
    

    simple and useful...

提交回复
热议问题