
SQL
Advanced SQL queries: CTEs, windows and rankings in one example
A query with three CTEs can look impressive while calculating the wrong sales total. I build one analysis step by step, keeping track of row meaning, missing values and the order of calculations.