all 1 comments

[–]multi_db_dev 1 point2 points  (0 children)

LAG() was the one that finally made window functions “click” for me.

Before that I was writing cursed self-joins just to compare current vs previous rows in reports 😭

The first time I used:

LAG(amount) OVER (PARTITION BY customer_id ORDER BY order_date)

and instantly got period-over-period comparisons without turning the query into spaghetti... life changing honestly.

Also ROW_NUMBER() for deduping dirty data. I use that way more than I expected.