SQL practice: LAG and LEAD
Chapter 24 · 9 questions · included in full access
Question 1 · easy
Solve it in your browserFor each customer, show each order date with their previous order date.
Question 2 · easy
Solve it in your browserFor each customer, show the number of days between each order and the previous one.
Question 3 · medium
Solve it in your browserFor each customer, show each order with the next order date.
Question 4 · medium
Solve it in your browserFind each customer's most recent order using LEAD being NULL.
Question 5 · medium
Solve it in your browserFor stock transfers, show each transfer with the previous transfer's quantity.
Question 6 · medium
Solve it in your browserShow monthly order counts with the previous month's count beside each one.
Question 7 · medium
Solve it in your browserShow monthly order counts and the change from the previous month.
Question 8 · hard
Solve it in your browserFor each employee within their branch, ordered by hire date, show who was hired just before them.
Question 9 · hard
Solve it in your browserFor each order, show the same customer's previous order date (NULL for their first order). First orders show another customer's date instead. Fix it.
These questions are part of full access.
The first chapters of every track are free. Full access is a one-time payment.
See pricing