Back to Topics

SQL Interview Questions

MCQ Quiz · All Difficulty Levels

1 · Choose Difficulty

2 · Number of Questions

3 · Timer per Question

Launch Quiz

Practice SQL interview questions with MCQs covering every query concept tested in technical interviews for data engineering, backend engineering, and analyst roles. Topics include SELECT statements and filtering, all JOIN types (INNER, LEFT, RIGHT, FULL OUTER, SELF, CROSS), GROUP BY and aggregate functions, subqueries and correlated subqueries, CTEs (Common Table Expressions), window functions (ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, SUM OVER), indexes and query optimization fundamentals, transactions and ACID properties, database normalization (1NF, 2NF, 3NF, BCNF), stored procedures and views, and NULL handling. SQL is tested at companies of every type, data-focused startups, SaaS product companies, financial institutions, and large tech firms, often as a hands-on coding round with real schema design. Four difficulty levels progress from Trainee (basic SELECT, filtering, simple JOINs) through Junior Dev (multiple JOINs, GROUP BY, subqueries) and Mid Level (CTEs, window functions, query plans, indexes) to Senior Dev (indexing strategy, transactions, normalization trade-offs, performance). Practice regularly to build the SQL fluency that interview rounds demand.

What this SQL quiz covers

Trainee

  • SELECT, ORDER BY and DISTINCT
  • UPDATE and DROP TABLE
  • Aliases with AS and LIKE patterns
  • Aggregates such as MIN() and UNIQUE constraints

Junior Developer

  • INNER and FULL OUTER JOIN
  • GROUP BY with HAVING
  • Views, COALESCE and ON DELETE CASCADE
  • Window functions and OFFSET

Mid-Level

  • Index trade-offs
  • Subqueries and recursive CTEs
  • Optimistic vs pessimistic locking, deadlocks
  • Partitioning and third normal form

Senior

  • Reading EXPLAIN plans
  • Why leading-wildcard LIKE is slow
  • Two-phase commit and the CAP theorem
  • Replication, point-in-time recovery and PgBouncer

Sample SQL Interview Questions

Ten representative questions from our full bank of SQL MCQs across all difficulty levels. Each one shows the correct answer and a short explanation. The interactive quiz above shuffles options and tracks your time per question.

  1. TraineeQ1

    What does SELECT retrieve?

    • Rows and columns from data sources Correct
    • Only schemas
    • Only backups
    • Only indexes
    Why: SELECT queries data from tables or expressions.
  2. TraineeQ2

    What does WHERE do?

    • Filters rows before grouping Correct
    • Creates tables
    • Deletes indexes
    • Starts transactions
    Why: WHERE filters individual rows before aggregation.
  3. TraineeQ3

    What is a primary key?

    • A unique non-null row identifier Correct
    • Any first column
    • A password
    • A view
    Why: Primary keys uniquely identify rows and cannot be null.
  4. TraineeQ4

    What does ORDER BY do?

    • Sorts result rows Correct
    • Groups rows
    • Deletes rows
    • Joins tables
    Why: ORDER BY controls result ordering.
  5. Junior DevQ5

    INNER JOIN returns?

    • Only matching rows from both sides Correct
    • All left rows
    • All rows always
    • Only nulls
    Why: INNER JOIN keeps rows that satisfy the join condition on both tables.
  6. Junior DevQ6

    LEFT JOIN returns?

    • All left rows plus matching right rows Correct
    • Only right rows
    • Only matching rows
    • No nulls ever
    Why: Unmatched right columns become NULL in a LEFT JOIN.
  7. Junior DevQ7

    GROUP BY is used with?

    • Aggregates per group Correct
    • Passwords
    • Backups
    • Indexes only
    Why: GROUP BY groups rows so aggregate functions apply per group.
  8. Mid LevelQ8

    What is an index tradeoff?

    • Faster reads, slower writes and more storage Correct
    • Slower reads always
    • No storage cost
    • Deletes constraints
    Why: Indexes speed lookup patterns but add maintenance cost on writes.
  9. Mid LevelQ9

    What is a transaction?

    • A unit of work committed or rolled back together Correct
    • A table name
    • A backup only
    • A cache
    Why: Transactions group changes with atomic commit or rollback.
  10. Senior DevQ10

    What does EXPLAIN help inspect?

    • Query execution plan Correct
    • Password policy
    • Schema comments only
    • Network TLS
    Why: EXPLAIN shows how the database plans to execute a query.

This is a static preview of 10 questions. Take the full interactive SQL quiz with timed rounds, all 25 questions per level, and instant score tracking.

Frequently Asked Questions: SQL Interviews

Common questions developers ask when preparing for SQL technical interviews.

What SQL topics are most commonly tested in data and backend interviews?

JOINs are almost always tested, interviewers want to see you write INNER, LEFT, and multi-table JOINs correctly. GROUP BY with aggregates, subqueries, and CTEs follow closely. Window functions (ROW_NUMBER, RANK, LAG, LEAD) are increasingly tested for analytics and data engineering roles. Query optimization (indexes, explain plans) and transaction concepts (ACID properties) come up in backend and senior data roles.

What is the difference between INNER JOIN and LEFT JOIN in SQL?

INNER JOIN returns only rows that have matching values in both tables, rows without a match in either table are excluded. LEFT JOIN (also called LEFT OUTER JOIN) returns all rows from the left table and matched rows from the right table; where there is no match, the right-table columns contain NULL. LEFT JOIN is used when you want to keep all records from the primary table regardless of whether related data exists in the second table.

What are window functions and when would you use them in SQL?

Window functions perform calculations across a set of rows related to the current row, unlike GROUP BY, they do not collapse rows into groups. Common window functions include ROW_NUMBER (unique sequential number per partition), RANK and DENSE_RANK (rankings with tie handling), LAG and LEAD (access previous/next row values), and SUM/AVG OVER (running totals and moving averages). They are essential for ranking queries, time-series analysis, and comparing rows within groups.

What is a CTE in SQL and how is it different from a subquery?

A Common Table Expression (CTE), defined with the WITH keyword, is a named temporary result set you can reference in the main query. Unlike a subquery, a CTE is defined once and can be referenced multiple times, making complex queries more readable and maintainable. Recursive CTEs can query hierarchical data (org charts, bill of materials). Most modern databases optimize CTEs similarly to subqueries, though there are database-specific differences in materialization.

How should I prepare for a SQL coding round in a technical interview?

Practice writing queries by hand against real schemas, do not rely on visual query builders. Focus on JOINs across three or more tables, GROUP BY with HAVING clauses, and at least two window function patterns. Study how to read a schema diagram quickly and identify which tables to JOIN. Review NULL handling, since many bugs in interview queries come from forgetting that aggregate functions ignore NULLs and that NULL comparisons require IS NULL rather than = NULL.