Topic
Window functions
Ranking, running totals, and comparing a row to its neighbours without collapsing the result set. This is the topic that most often separates a mid-level candidate from a junior one, and PARTITION BY is where it goes wrong.
New to this? Read the Window functions chapter.Prefer a fixed order? Window functions deep-dive.
easyRank grocery items by price within each categoryFoodpanda · windowFree→easyShow each customer's previous purchase amountLotus's · windowFree→easyShow every top-up next to the overall averageTouch 'n Go · windowFree→mediumNumber each subscriber's reloads in orderU Mobile · windowFree→mediumRunning balance for each e-walletBoost · windowFree→hardBusiest data center in each regionAlibaba · windowBasic→hardDay-over-day change in order volumeGrabFood · windowBasic→hardDrivers delayed 3+ days in a rowNinja Van · windowBasic→hardMonth-over-month change in units soldSony · windowBasic→hardPrevious month's revenueGrab · windowFree→hardRank customers by spendMaybank · windowBasic→hardRank customers by transaction amount, per branchHSBC · windowBasic→hardRank projects by margin within each practiceAccenture · windowBasic→hardRunning total of daily salesShopee · windowFree→hardSecond most expensive product per categoryLazada · windowFree→hardShow each customer's previous tier alongside their new oneGXBank · windowBasic→hardSplit customers into spending quartilesShopee · windowBasic→