TOP-N分析练习

  1. 请列出年龄最大的两个人的姓名:

    sql

    SELECT name

    FROM people

    ORDER BY age DESC

    FETCH FIRST 2 ROWS ONLY;

  2. 请列出工资最高的两个人的信息:

    sql

    SELECT *

    FROM employees

    ORDER BY salary DESC

    FETCH FIRST 2 ROWS ONLY;

  3. 请列出第3-5个人的信息(根据工资排序):

    sql

    SELECT *

    FROM employees

    ORDER BY salary DESC

    OFFSET 2 ROWS FETCH NEXT 3 ROWS ONLY;