SQL practice: FIRST_VALUE, LAST_VALUE, and NTH_VALUE
Chapter 24B · 3 questions · included in full access
Question 1 · easy
Solve it in your browserFor 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.
Question 2 · easy
Solve it in your browserShow 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.
Question 3 · hard
Solve it in your browserFor 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.
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing