# SQL Level 11: Advanced SQL

> Level 11: Advanced SQL of the LoWisa SQL course: Recursive Queries, Advanced Grouping and Set Operations, Complex Relational Patterns. 3 lessons and 9 ideas, each explained in one line.

Advanced SQL is level 11 of 15 of the [LoWisa SQL course](/courses/sql/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## 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](/courses/sql/level-10-indexes-and-query-planning/): Index Structures, Query Execution Plans, Diagnosing Slow Queries.
- **Next:** [Level 12: Security](/courses/sql/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](/help/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.

## Learn SQL on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/sql/level-11-advanced-sql/ · Updated 2026-11-16
