SQL Window Functions: Querying Multiple Aggregation Levels at Once

Most SQL aggregations collapse your data to a single grain. Window functions break that constraint: here's how to compute row-level, group-level, and grand-total metrics in a single query without losing any rows.