PrepZone Logo
PrepZone
Back to Database

Database · Medium

Get the first and the most recent order for each customer in a single row.

DatabaseSQL QueriesSeniorWindow Functions

Answer preview

Collapse each customer's order history to one row with FIRST_VALUE/LAST_VALUE over the whole partition — the frame is the part everyone gets wrong.…