For each order, show the order id, customer_id, order_date, total_amount, and the sequence number of that order for the customer (1st order, 2nd order, etc.). Also show the previous order's total_amount using LAG. Sort by customer_id, then sequence number.
Schema
🔑idINT
🔗customer_idINT
order_dateTEXT
statusTEXT
total_amountREAL
postgresql
Run your query to see results
Press Ctrl + Enter to execute