SQL-Engineering-Handbook

Question Index

Current count: 92 questions across all 10 competency levels (numbered 0–9).

ID Title Level Difficulty Type Category
Q001 Filter and Sort Department Staff 0 🟢 A WHERE, ORDER BY
Q002 NULL in a Comparison 0 🟢 B NULL basics
Q003 COUNT(*) vs. COUNT(column) 0 🟢 F Aggregation basics
Q004 Aliasing and Reserved Words 0 🟢 C Aliases, data types
Q005 Logical Processing Order 0 🟡 E Logical processing order
Q006 Department Headcount with Zero-Count Departments 1 🟡 A Joins, Aggregation
Q007 IN vs. EXISTS with NULLs 1 🟠 F Subqueries
Q008 UNION vs. UNION ALL Correctness 1 🟡 F Set Operators
Q009 CTE Readability vs. Correctness 1 🟡 C CTEs
Q010 CASE Expression in Aggregation 1 🟡 A CASE, Conditional Aggregation
Q011 Rank Employees by Salary Within Department 2 🟡 A Window Functions, Ranking
Q012 RANK vs. DENSE_RANK vs. ROW_NUMBER 2 🟡 F Window Functions
Q013 Running Total 2 🟠 A Window Functions
Q014 Gaps and Islands 2 🔴 A Window Functions, Advanced Pattern
Q015 LAG for Period-over-Period Comparison 2 🟡 A Window Functions
Q016 Deduplication with ROW_NUMBER 2 🟡 A Window Functions, Data Cleaning
Q017 SARGability Diagnosis 4 🟠 C Indexing
Q018 Reading an Execution Plan 4 🔴 H EXPLAIN
Q019 Composite Index Column Order 4 🟠 I Indexing
Q020 Lost Update Diagnosis 4 🔴 J Transactions, Concurrency
Q021 Deadlock from Reversed Lock Order 4 ⚫ J Transactions, Deadlocks
Q022 “Revenue Numbers Disagree Between Two Reports” 6 🔴 G Data Reasoning
Q023 “Daily Pipeline Started Producing Duplicate Records” 6 ⚫ J Data Quality
Q024 “Query Became 20x Slower After Deployment” 6 🔴 J Performance Regression
Q025 “Index Exists but Isn’t Being Used” 6 🟠 H Indexing
Q026 Recursive CTE: Org Chart Traversal 3 🔴 A Recursive CTEs
Q027 Relational Division: Employees with ALL Required Certifications 3 🔴 A Relational Division
Q028 Correlated Subquery for Percent-of-Total 3 🟠 F Correlated Subqueries, Window Functions
Q029 Conditional Aggregation for a Pivot Report 3 🟠 A Conditional Aggregation
Q030 Temporal Reconciliation: Detecting Overlapping Date Ranges 3 🔴 A Temporal Analysis
Q031 Data Quality: Finding Orphaned Foreign Keys Without a Constraint 3 🟠 G Data Quality, Reconciliation
Q032 E-commerce: Customer Lifetime Value Ranking 5 🟠 A E-commerce, Window Functions
Q033 Fintech: Detecting Potential Duplicate Transactions 5 🔴 A Fintech, Fraud Detection
Q034 SaaS: Monthly Recurring Revenue (MRR) Waterfall 5 🔴 A SaaS, Subscription Analytics
Q035 Healthcare: Readmission Rate Within 30 Days 5 🟠 A Healthcare, Temporal Analysis
Q036 Logistics: Identifying Delayed Shipments with SLA Breach 5 🟡 A Logistics
Q037 Schema Design Tradeoff: Wide Table vs. EAV 7 ⚫ I Schema Design
Q038 Query Review: Spotting an Unmaintainable Query 7 🔴 I Query Architecture, Maintainability
Q039 Performance Tradeoff: Denormalization Decision 7 ⚫ I Schema Design, Performance
Q040 Data Contract: API Change Silently Breaks a Downstream Report 7 ⚫ J Data Contracts, Technical Debt
Q041 How to Select Questions for a Given Role 8 Meta Meta  
Q042 Evaluating Reasoning vs. Memorization 8 Meta Meta  
Q043 Scoring a Candidate Who Uses a Different-But-Valid Approach 8 Meta Meta  
Q044 Running a Fair 30-Minute Screen Under Time Pressure 8 Meta Meta  
Q045 Design a Reporting Database for a Growing Company 9 ⚫ I System Design
Q046 Design a Subscription Revenue Model 9 ⚫ I System Design, SaaS
Q047 Design a Fraud Analytics Query System 9 ⚫ I System Design, Fintech
Q048 Design a High-Volume Event Analytics System 9 ⚫ I System Design, Data Warehousing
Q049 DISTINCT vs. GROUP BY 0 🟢 F DISTINCT, GROUP BY
Q050 Multi-Column ORDER BY Direction 0 🟢 B ORDER BY
Q051 LIKE Wildcards and Index Usage 0 🟢 F LIKE, Pattern Matching
Q052 Three-Table Join Direction 0 🟢 A JOIN
Q053 BETWEEN and Date Range Inclusivity 0 🟡 C BETWEEN, Dates
Q054 Self-Join to Find a Manager’s Name 1 🟡 A Self-Join
Q055 HAVING vs. WHERE on the Same Query 1 🟡 C HAVING, WHERE
Q056 Three-Table Join with Aggregation 1 🟠 A Joins, Aggregation
Q057 Correlated Subquery in the SELECT List 1 🟠 F Correlated Subquery
Q058 COALESCE Inside an Aggregate 1 🟡 A NULL Handling, Aggregation
Q059 NTILE for Salary Quartiles 2 🟡 A Window Functions
Q060 FIRST_VALUE with an Explicit Frame 2 🟠 C Window Functions, Frames
Q061 PERCENT_RANK vs. CUME_DIST 2 🟠 F Window Functions
Q062 Multi-Column PARTITION BY 2 🟡 A Window Functions
Q063 Moving Average with a ROWS Frame 2 🟠 A Window Functions, Frames
Q064 Recursive CTE: Downward Org Chart (All Reports) 3 🔴 A Recursive CTEs
Q065 Conditional Aggregation as a Manual Pivot 3 🟠 A Pivot, Conditional Aggregation
Q066 Set-Based Thinking vs. Row-by-Row Procedural Logic 3 🟠 F Query Design Philosophy
Q067 Covering Index Concept 4 🟠 F Indexing
Q068 Index Selectivity and Cardinality 4 🟠 F Indexing, Query Planning
Q069 Isolation Level and a Non-Repeatable Read 4 🟠 B Transactions, Isolation
Q070 Fintech: Reconciliation Deduplication 5 🟠 A Fintech, Deduplication
Q071 SaaS: Monthly Cohort Retention 5 🟠 A SaaS, Cohort Analysis
Q072 Logistics: Late Delivery Root-Cause Segmentation 5 🟠 A Logistics, Segmentation
Q073 “This Query Was Fast Last Month, Now It’s Slow” 6 🔴 G Data Reasoning
Q074 Reproducing an Intermittent Deadlock 6 🔴 G Concurrency, Data Reasoning
Q075 Designing an Idempotent Batch Job 7 ⚫ I Batch Processing, Idempotency
Q076 Normalization vs. Denormalization for a Read-Heavy Service 7 ⚫ I Schema Design
Q077 Calibrating Hints When a Candidate Is Stuck 8 Meta Meta  
Q078 Evaluating Whiteboard SQL Without Running It 8 Meta Meta  
Q079 Design an Append-Only Audit Log for Compliance 9 ⚫ I System Design, Compliance
Q080 Design Tenant Isolation for a Multi-Tenant SaaS Schema 9 ⚫ I System Design, Multi-Tenancy
Q081 INNER JOIN vs. LEFT JOIN with a Filter 1 🟡 C Joins, WHERE
Q085 Subquery in FROM (Derived Table) vs. CTE 1 🟡 F CTEs, Derived Tables
Q086 GROUP BY with an Expression, Not Just a Column 1 🟡 A GROUP BY, Date Functions
Q088 Running Total Reset Per Group 2 🟡 C Window Functions, Running Totals
Q089 Top-N Per Group 2 🟠 A Window Functions, Top-N
Q090 Percent of Department Total 2 🟡 A Window Functions
Q091 Detecting Consecutive Salary Increases 2 🟠 A Window Functions, Gaps and Islands
Q092 CUME_DIST: Proportion of Employees at or Below This Salary 2 🟠 A Window Functions, Percentiles
Q093 Join Fan-Out Silently Inflates a SUM 1 🟠 C Joins, Grain
Q094 GROUP BY Alias vs. WHERE Alias 1 🟡 C Logical Processing Order, Aliases
Q095 NOT and the Law of Excluded Middle 1 🟠 B NULL Handling, Boolean Logic
Q096 LEAD to Find Days Until the Next Hire in a Department 2 🟡 A Window Functions

By level: L0: 10 · L1: 16 · L2: 17 · L3: 9 · L4: 8 · L5: 8 · L6: 6 · L7: 6 · L8: 6 · L9: 6

By difficulty: 🟢: 8 · 🟡: 23 · 🟠: 28 · 🔴: 14 · ⚫: 13 · Meta (interviewer): 6 (not difficulty-rated, per format spec)

By type: A: 35 · B: 4 · C: 10 · E: 1 · F: 13 · G: 4 · H: 2 · I: 12 · J: 5 · Meta: 6

Retired IDs

Q082, Q083, Q084, Q087 — retired and never reassigned, per the ID policy in TAXONOMY_AND_FORMAT.md (“assigned once, never reused even if retired”). Each was found to be a semantic duplicate of an already-existing question during a post-expansion audit (Q082≈Q008, Q083≈Q007, Q084≈Q010, Q087≈Q015 — see AUDIT_REPORT.md §3) and was removed outright rather than content-swapped in place, which the original fix mistakenly did before this policy conflict was caught and corrected. The replacement concepts that earned a place in the bank now live at genuinely new IDs: Q093 (was briefly at Q082), Q094 (was Q083), Q095 (was Q084), Q096 (was Q087). No ID in this bank will ever point to two different questions over time.