Change from the Previous Order

medium
Unit 12 · Window Functions V0/3 to milestone

For every order, return customer_id, order_date, total and change: how much bigger (positive) or smaller (negative) it was than that customer's previous order, or NULL for their first order. Sort by customer_id, then order_date.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#lag1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Change from the Previous Order · TechGradify