Showing posts with label top-N query.. Show all posts
Showing posts with label top-N query.. Show all posts

Monday, 5 November 2012

How to get the five highest-paid people—a top- N query

SELECT *
  FROM (SELECT *
            FROM emp
        ORDER BY sal DESC)
 WHERE ROWNUM <= 5;