SQL practice: ROW_NUMBER, RANK and DENSE_RANK

Chapter 23 · 10 questions · included in full access

  1. Question 1 · easy

    Number the products within each category, most expensive first.

    Solve it in your browser
  2. Question 2 · easy

    Rank all employees by salary, highest first, using RANK().

    Solve it in your browser
  3. Question 3 · medium

    Rank all employees by salary using DENSE_RANK() and compare with 23-2.

    Solve it in your browser
  4. Question 4 · medium

    Number each customer's orders from oldest to newest.

    Solve it in your browser
  5. Question 5 · medium

    Rank branches by how many orders they have.

    Solve it in your browser
  6. Question 6 · medium

    Rank products within each category by total quantity sold.

    Solve it in your browser
  7. Question 7 · medium

    Number all employees by salary within their role.

    Solve it in your browser
  8. Question 8 · medium

    Find the 2nd highest salary in the company using DENSE_RANK() inside a CTE.

    Solve it in your browser
  9. Question 9 · hard

    Explain when ROW_NUMBER() and RANK() would give different answers on our employees table.

    Solve it in your browser
  10. Question 10 · hard

    Show the cheapest product in each category. Only one row comes back. Fix it.

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing