Recursive Queries
- Recursive CTEs. A recursive CTE seeds with base rows and re-applies itself: trees and graphs walked in pure SQL.
- Hierarchies. Org charts and category trees resolve with recursion: each pass joins children to the frontier so far.
- Termination. Recursion needs a floor: a depth guard or cycle check keeps a looped graph from running forever.
Advanced Grouping and Set Operations
- UNION and friends. UNION stacks compatible results (deduplicated), UNION ALL keeps duplicates, INTERSECT and EXCEPT compare sets.
- GROUPING SETS. GROUPING SETS, ROLLUP and CUBE compute several grains in one pass: subtotal reports without copy-paste.
- FILTER and pivots. Conditional aggregation: COUNT with FILTER: pivots categories into columns inside one query.
Complex Relational Patterns
- Anti-joins. The anti-join: NOT EXISTS: finds rows with no match: customers who never ordered, cleanly and fast.
- Greatest-n-per-group. Latest order per customer is the classic: window rank then filter, or a lateral join where supported.
- JSON in SQL. Modern engines index and query JSON columns: flexible payloads without abandoning relational ground.
Before and after this level
- Before: Level 10: Indexes & Query Planning: Index Structures, Query Execution Plans, Diagnosing Slow Queries.
- Next: Level 12: Security: Users, Roles and Permissions, SQL Injection Awareness, Secure Database Access.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does SQL Level 11: Advanced SQL cover?
Recursive Queries, Advanced Grouping and Set Operations, Complex Relational Patterns: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 10: Indexes & Query Planning, which covers Index Structures, Query Execution Plans, Diagnosing Slow Queries.