Back to M0 — SQL + Python Screens

SQL Screen Drills (Timed Sets)

Outcome: Clear timed set (gaps-islands/recursive-CTE/EXPLAIN) Curated video (CodeEra): Top 5 SQL Window Function Questions for Interviews (With Solutions) — https://www.youtube.com/watch?v=LoS_U22CW_E (verified live via yt-dlp 2026-09-24). Pointer: DA-track-mapped timed sets; shell: courses/video-scripts/ds-interview-prep/01.md.

9 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. Pattern-First Solving — Establishes rapid archetype identification and structured CTE design under timed interview constraints.
  2. Gaps and Islands Architecture — Demonstrates the row-number difference technique to compute contiguous historical streaks.
  3. Dedupe Windows Setup — Applies deterministic window ranking functions to isolate primary entity states without losing attributes.
  4. Recursive CTE Construction — Walks through building anchor members and recursive joins for tree-structured hierarchies.
  5. EXPLAIN Plan Diagnosis — Reviews execution plans to identify query bottlenecks and articulate performance trade-offs.
PDF notes

Frequently asked questions

When should I use ROW_NUMBER() versus DENSE_RANK() for deduplication?

Use ROW_NUMBER() when you must guarantee exactly one unique row per partition. Use DENSE_RANK() when ties must be preserved collectively.

How does DATE_SUB identify continuous streaks in gaps-and-islands?

As both consecutive dates and row numbers increment by one daily, subtracting the row number from the date produces an invariant reference date for contiguous records.

What should I look for first in an EXPLAIN output during an interview?

Check for unexpected sequential scans on large tables and expensive Sort operations that could be mitigated via index coverage.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.