Micro Free Course — 100% Free Learning

All lessons in this module are free to learn. Sign in with Google to save your progress.

1

Interview SQL Patterns

The named interview classics: Nth-highest, gaps-and-islands, pivoting without PIVOT, recursive CTEs, custom date bucketing, and set operations. Memorize the shapes — these recur in every screen.

Module Progress0% Complete
120 min total
12 Lessons
0 Completed

Module Content

The Nth Highest Salary Problem

The most-asked SQL interview question of all time. Five wrong answers, two right ones. FIND_VIDEO: search 'nth highest salary SQL leetcode' — recommended channel: Joma Tech / Alex Freberg. Aim for 9 min or under.

9 minVideo
Start

Recap — Why People Get Nth Highest Wrong

The trap, the standard answer, and how to extend it when the interviewer adds 'handle ties'.

10 minTutorial
Start

Consecutive Days, Sessions — Gaps and Islands

The pattern behind 'consecutive logins', 'session detection', 'streaks' — one of the SQL world's named techniques. FIND_VIDEO: search 'SQL gaps and islands consecutive days' — recommended channel: Itzik Ben-Gan / Modern SQL. Aim for 12 min or under.

12 minVideo
Start

Recap — The Gaps and Islands Pattern

Once you see the trick, you'll see this everywhere — login streaks, session bounds, contract gaps.

11 minTutorial
Start

Pivot Using CASE WHEN — Cross-Database Compatibility

PIVOT is vendor-specific. CASE WHEN works everywhere. Here's the canonical pattern. FIND_VIDEO: search 'SQL pivot CASE WHEN tutorial' — recommended channel: Alex Freberg / EverSQL. Aim for 9 min or under.

9 minVideo
Start

Recap — CASE WHEN Pivoting

Converting long-format data into wide-format columns — the universal SQL idiom.

10 minTutorial
Start

Recursive CTEs — Org Charts and Hierarchies

The one SQL feature most analysts never use — and the one that solves 'show me all descendants' in 10 lines. FIND_VIDEO: search 'recursive CTE SQL hierarchical query' — recommended channel: Modern SQL / Itzik Ben-Gan. Aim for 11 min or under.

11 minVideo
Start

Recap — Building Recursive Queries

The recursive CTE pattern: base case + recursive case + termination. Same in every database.

10 minTutorial
Start

Custom Date Buckets — Fiscal Weeks and Rolling Windows

When DATE_TRUNC isn't enough — custom fiscal calendars, rolling buckets, ISO weeks. FIND_VIDEO: search 'SQL date bucketing fiscal calendar' — recommended channel: EverSQL. Aim for 10 min or under.

10 minVideo
Start

Recap — Date Bucketing Recipes

The four date-bucketing patterns every BI analyst hits, with the SQL for each.

9 minTutorial
Start

EXCEPT, INTERSECT, UNION — For Diffs and Dedup

When self-joins are overkill — the set operations every analyst should reach for. FIND_VIDEO: search 'SQL EXCEPT INTERSECT UNION ALL' — recommended channel: Modern SQL. Aim for 9 min or under.

9 minVideo
Start

Recap — Choosing the Right Set Op

UNION vs UNION ALL, EXCEPT vs LEFT JOIN, INTERSECT vs INNER JOIN. Same answers, different speeds and clarity.

9 minTutorial
Start