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

前端 未结 12 2489
说谎
说谎 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:02

    You can find the Nth largest value of a column by using the following query

    SELECT * 
    FROM TableName a 
    WHERE n = (
               SELECT count( DISTINCT (b.ColumnName) )
               FROM TableName b 
               WHERE a.ColumnName <= b.ColumnName 
              );
    

提交回复
热议问题