How to Actually Remember
All This SQL

You don't memorize SQL by reading a cheatsheet 10 times. You memorize it by pattern-matching, drilling under pressure, and writing skeletons from memory. Here's the plan.

15
core patterns to own
Phase 1 · 30 min

Build the Pattern Map in your head

Don't read the cheatsheet — quiz yourself on it. Go to the Flashcard tab and flip through all 15 patterns. For each card:

  • Say the SQL tool out loud before flipping
  • Rate yourself: Got it / Missed it
  • Repeat only the missed ones until clean

Goal: zero misses on 3 consecutive passes.

Phase 2 · 20 min

Pattern → SQL Tool Reflexes

Use the Quick-Fire Drill tab. You see a trigger phrase, you pick the SQL tool in under 3 seconds — no thinking, just reflex. This trains the interviewer → you step: they say "top N per group", your hand is already typing ROW_NUMBER() OVER (PARTITION BY...).

Target: ≥80% accuracy before moving on.

Phase 3 · 30 min

Write the 10 Skeletons From Memory

Open a blank editor. Write each skeleton without looking — just from the pattern name. Check against the Cheatsheet tab after each one. The act of retrieving beats re-reading every time.

  • Start with ① Filter→Aggregate→Having (easiest)
  • Then ② Anti-Join, ③ Top-N, ④ Running Total
  • Finish with ⑨ SCD Type-2 and ⑩ Session (hardest)
Phase 4 · 15 min/day

Daily Spaced Repetition Micro-Drills

The enemy is forgetting. Beat it with 15-minute daily sessions:

  • Day 1: All 15 flashcards + write 5 skeletons
  • Day 2: Only the ones you missed + 3 skeletons
  • Day 3–5: Quick-Fire Drill only (10 min)
  • Day 6: Full mock problem from scratch
The Interview Room

The 60-Second Mental Checklist

When they ask a question, say this script out loud:

  • 1. "So I need one row per [X], showing [metric], filtered to [Y]."
  • 2. Name the tables and the join type.
  • 3. "This is a [pattern name] pattern."
  • 4. Write the skeleton stubs first, then fill in.
  • 5. Narrate the edge cases (NULLs, COALESCE, NULLIF).
Memory Hooks

The 3 Hardest Patterns — Mnemonics

  • LAG = "LAst Gone" → previous row
  • LEAD = "Look Elsewhere Ahead Daily" → next row
  • SCD Type-2 = "Sandwich Date: order time BETWEEN start AND end"
  • ROWS BETWEEN 6 PRECEDING = 7-day window (6+today=7)
  • Anti-join = "LEFT JOIN, look for the ghost" (IS NULL)

Pattern Flashcards

Click a card to reveal the answer. Mark yourself honestly.

0 / 15 reviewed
Pattern
Loading...
click to reveal →
SQL Tool
Card 1 of 15

Quick-Fire Drill

See the trigger phrase → pick the SQL tool. Train your reflexes.

0Correct
0Wrong
0Streak 🔥
0Total
Trigger phrase
Loading...

Pattern Cheatsheet

All 15 patterns at a glance. Reference while you practice.

The 60-Second Interview Answer Flow
1
Restate the output (10 sec)

"So I need one row per [X], showing [metric], filtered to [condition]."

2
Identify tables & joins (10 sec)

"I need orders joined to users. Because I want users with NO refund — that's a LEFT JOIN."

3
Name the pattern (5 sec)

"This is an anti-join pattern" or "This needs ROW_NUMBER() OVER (PARTITION BY user)"

4
Write skeleton → fill in (20 sec)

Write WITH / SELECT / FROM / WHERE / GROUP BY / HAVING stubs. Then populate column names.

5
Narrate edge cases (15 sec)

"I'm using COALESCE here because refund_amount could be NULL. Also NULLIF to avoid divide-by-zero."

All 15 Patterns
Trigger PhraseSQL ToolSkeleton Tip
NULL & Edge Case Checklist
Edge CaseHow to Handle
end_date NULLMeans "still active". end_date IS NULL OR end_date >= :date
Missing JOIN valueCOALESCE(r.amount, 0) — LEFT JOIN right-side cols will be NULL
Divide by zero (CTR)NULLIF(denominator, 0)1.0 * num / NULLIF(denom, 0)
COUNT(*) vs COUNT(col)COUNT(*) counts all rows; COUNT(col) skips NULLs
Duplicates in sourceUse ROW_NUMBER()=1 or DISTINCT before aggregating
Timezone (yesterday UTC)DATE(CONVERT_TZ(ts,'local','UTC')) or AT TIME ZONE
SCD effective_end NULLCurrent record → COALESCE(effective_end, '9999-12-31')