Skip to main content
All Problems
hard0% acceptance

Compare Each Order to Previous and Next

For each customer's orders (ordered by date), show the current order's total_amount alongside the previous order's amount and the next order's amount. Also compute the change from the previous order. Return customer_id, order_date, total_amount, prev_amount, next_amount, and amount_change.

Schema

🔑idINT
🔗customer_idINT
order_dateTEXT
statusTEXT
total_amountREAL
postgresql

Run your query to see results

Press Ctrl + Enter to execute