Top n distinct values of one column in Oracle
问题 I'm using a query where a part of it gets the top 3 of a certain column. It creates a distinct subquery of the column, limited by 3 number of rows, and then filters those rows to the main query to do the top 3. WITH subquery AS ( SELECT col FROM ( SELECT DISTINCT col FROM tbl ) WHERE ROWNUM <= 3 ) SELECT col FROM tbl WHERE tbl.col = subquery.col So the original table is like this: col ----- a a a b b b c d d e f f f f And the query returns the top 3 of the column (not the top 3 rows which