SQL practice: FIRST_VALUE, LAST_VALUE, and NTH_VALUE

Chapter 24B · 3 questions · included in full access

  1. Question 1 · easy

    For every order, show the order_id, customer_id, order_date, and the order_date of that customer's FIRST order. Name it first_order_date. Use FIRST_VALUE.

    Solve it in your browser
  2. Question 2 · easy

    Show the product_name, unit_price, and the unit_price of the 3rd most expensive product in the catalog. Name it third_highest_price. Use NTH_VALUE across the entire table.

    Solve it in your browser
  3. Question 3 · hard

    For each order, show order_id, customer_id, order_date, and that customer's final order_date as last_order_date. Use LAST_VALUE(order_date) with an explicit frame ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.

    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