10 SQL Traps
Ten queries that run without errors and still return the wrong answer, and how to catch each one.
Watch the trapsLearn real-world SQL · SQL Server
Query Detective finds the SQL traps that don't throw errors: NULLs, ties, duplicates and bad data that quietly change your numbers. Short fixes, full courses and realistic business data.
SELECT CustomerID FROM Customers WHERE CustomerID NOT IN ( SELECT CustomerID FROM Orders );
The clue: one NULL in Orders.CustomerID makes NOT IN match nothing. Use NOT EXISTS.
Learn SQL in one sitting, with chapters so you can jump to any lesson. Start with the fundamentals, then go deeper.
JOINs, WHERE, ORDER BY, GROUP BY, HAVING, CASE WHEN, subqueries, views and CTEs: the queries analysts write every day.
OVER, PARTITION BY, ROW_NUMBER, RANK vs DENSE_RANK, NTILE, LAG, LEAD, the LAST_VALUE trap and running totals.
Pick the format that fits your time.
Ten queries that run without errors and still return the wrong answer, and how to catch each one.
Watch the trapsA story-driven investigation of an undocumented billing database, one clue at a time, all the way to the CFO.
Follow the caseOne technique per Short: TRY_CAST, TOP WITH TIES, ORDER BY NEWID(), NULLIF and more.
Watch the ShortsNew SQL tips every week. Same detective, wherever you scroll.
Created by Srini Voleti.
I'm a working data analyst who teaches SQL the way it's used on the job: with messy data, real business questions and results that have to be right. Examples use realistic synthetic datasets from everyday business: orders and customers, subscriptions and billing, and healthcare-style claims.
DatabaseSQL Server (T-SQL)AudienceData analysts, report developers and anyone preparing for SQL interviewsDataSynthetic business and healthcare-style datasets. No real patient, customer or company data.