Interview Q&A · SQL

SQL Interview Questions & Answers

All 192 SQL interview questions — fundamentals, filtering, aggregations, JOINs, constraints, set operations, subqueries and CTEs, window functions, indexes, transactions, design and security — with correct, modern answers. This bank holds 192 questions across 17 topics and 12 topic groups. Every answer is written for current SQL versions, and each topic links to matching course lessons where they exist.

192 questions answered17 topics12 topic groups
Pick a topic

Every topic below links to its own page with all of its questions in one place.

Read the answer

Answers are checked against current language behaviour; old-guide claims are corrected.

Jump both ways

Each topic points to the matching course lesson, and lessons point back here.

SQL Fundamentals

18 questions across 2 topics — What SQL is, database thinking, sublanguages and the execution pipeline.

SELECT & Filtering

24 questions across 2 topics — Projection, execution order, WHERE depth, LIKE, IN, NULLs and sargability.

Modifying Data

10 questions across 1 topic — Guarded UPDATE/DELETE, upserts, bulk loads and lost-update defenses.

Aggregations & GROUP BY

14 questions across 1 topic — Aggregate functions, grouping, HAVING, pivots and top-N-per-group.

JOINs

14 questions across 1 topic — Every join type, ON vs WHERE, fan-out control and join performance.

Constraints & Keys

12 questions across 1 topic — Primary/foreign keys, uniqueness, checks and cascading actions.

Set Operations

10 questions across 1 topic — UNION, INTERSECT and EXCEPT — combining result sets correctly.

Subqueries, CTEs & Views

22 questions across 2 topics — Nesting, decorrelation, recursive CTEs and views as interfaces.

Window Functions

14 questions across 1 topic — Ranking, running totals, LAG/LEAD and frame semantics.

Indexes & Transactions

22 questions across 2 topics — B-trees, EXPLAIN, ACID, isolation levels and locking.

Design & Security

12 questions across 1 topic — Schema design, key strategies, migrations and injection defense.

Scenarios & Rapid Fire

20 questions across 2 topics — Production judgment calls, plus one-line revision for the night before.

Recommended resourcesAffiliate links · may earn us a commission

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits