SQL 13. Grouping Sets, Rollups, and Self-Joins
Overview In SQL interviews, understanding advanced grouping and join techniques is crucial. This post dives into GROUPING SETS, ROLLUP, CUBE, and types of joins like self-joins, CROSS JOIN, and NATURAL JOIN. We also touch on how to interpret NULLs in grouping results and share interview tips along the way. 1. GROUPING SETS GROUPING SETS let you define multiple GROUP BY combinations in a single query—ideal for multi-dimensional reports. Problem You want to calculate: ...