Learn
SQL
Query topics as they actually come up in interviews — joins, window functions, CTEs and the analytics patterns built on them, each with runnable queries.
Articles16
Aggregation, GROUP BY and HAVING
3 minGROUP BY, HAVING, and the conditional-aggregation trick that answers half of all reporting questions.
CASE, Pivoting and Unpivoting
3 minCASE inside an aggregate is the portable pivot — rows become columns without any vendor-specific syntax.
CTEs and Recursive CTEs
3 minName your intermediate steps with WITH — then use the recursive form to walk hierarchies and generate sequences.
Date and Time Functions
3 minTruncate to group, add intervals to shift, and always use half-open ranges on timestamps.
Finding and Removing Duplicates
3 minGROUP BY HAVING to find them, ROW_NUMBER to delete all but one — and what to do when there is no primary key.
Gaps, Islands and Streaks
3 minThe row-number difference trick that turns consecutive runs, streaks and missing dates into one grouping problem.
Indexes, Query Performance and Full-Text Search
4 minWhy a query is slow: index structure, the leftmost-prefix rule, sargable predicates, and how to read EXPLAIN.
INSERT, UPDATE, DELETE and DDL
4 minChanging data and schema safely — including the DELETE/TRUNCATE/DROP distinction that gets asked in every SQL interview.
NULL Handling
3 minNULL is 'unknown', not 'empty' — and that one distinction explains every surprising result it produces.
SELECT, DISTINCT, ORDER BY and LIMIT
3 minThe clauses every query starts with — and the logical execution order that explains why aliases work in some places and not others.
Set Operations
3 minStacking result sets: UNION vs UNION ALL, plus INTERSECT and EXCEPT and how to fake them where they are missing.
SQL JOINs
3 minEvery join type, the ON-versus-WHERE rule that silently breaks LEFT JOINs, and the self-join for hierarchies.
String and Numeric Functions
3 minSlicing text and rounding numbers — including the integer-division trap that silently returns 0.
Subqueries and EXISTS
3 minScalar, correlated and derived subqueries — plus when EXISTS is the right answer and when a JOIN is.
WHERE, Filtering and Pattern Matching
4 minEvery row filter, plus the two traps that silently return wrong rows: NOT IN with NULLs, and functions on indexed columns.
Window Functions
3 minAggregate without collapsing rows — ranking, running totals, and comparing each row to its neighbours.
Topics40
Every topic on the SQL sheet, in the order the sheet works through them. 40 of 40 have a written guide so far — the rest link straight to their questions on the sheet.
- Basic SELECTGuide
- FilteringGuide
- SortingGuide
- AggregationGuide
- Limiting ResultsGuide
- DistinctGuide
- NULL HandlingGuide
- Pattern MatchingGuide
- AliasesGuide
- String OperationsGuide
- Date FunctionsGuide
- Numeric FunctionsGuide
- GROUP BYGuide
- HAVING ClauseGuide
- DuplicatesGuide
- Data ManipulationGuide
- Date OperationsGuide
- Row OperationsGuide
- SubqueriesGuide
- RankingGuide
- AlternativesGuide
- JOINsGuide
- Set OperationsGuide
- DDLGuide
- Conditional LogicGuide
- Window FunctionsGuide
- Complex JOINsGuide
- CTEGuide
- Recursive CTEGuide
- PivotingGuide
- UnpivotingGuide
- Statistical FunctionsGuide
- Gap AnalysisGuide
- Date SequencesGuide
- AnalyticsGuide
- Full-Text SearchGuide
- Streak AnalysisGuide
- PerformanceGuide
- Date Range AnalysisGuide
- String AggregationGuide
Related
SQL sheet
Practise the topics above and track what you have solved.
DSA Patterns articles
The recurring shapes behind interview problems — what each pattern is, when it applies, the template that solves it, and the mistakes that cost people the round.
System Design articles
Design problems worked end to end: requirements, back-of-envelope numbers, the architecture, and the trade-offs an interviewer will push on.