SQL Interview Questions (2026) — 16 Real Questions + AI Mock Interview

SQL interviews are deceptively hard: the syntax is small, but interviewers use it to test how you think about data. Expect joins, aggregation, window functions, indexing, and a live query-writing round for data, backend, and analytics roles. In 2026, the bar has risen on performance and window functions specifically. Below are the SQL questions asked most often, with what a senior interviewer wants to hear in each answer.

16 SQL interview questions you'll actually get asked

  1. 1. Explain INNER vs LEFT vs RIGHT vs FULL OUTER JOIN.

    How a senior interviewer scores this: Describes which rows survive each join and can draw the Venn picture without hesitating.

  2. 2. WHERE vs HAVING — what's the difference?

    How a senior interviewer scores this: WHERE filters rows before grouping, HAVING filters groups after aggregation.

  3. 3. Write a query to find the second-highest salary.

    How a senior interviewer scores this: Handles ties and NULLs; offers a window-function (DENSE_RANK) and a subquery approach.

  4. 4. What is an index, and when does it hurt rather than help?

    How a senior interviewer scores this: Speeds reads, slows writes; knows over-indexing and low-selectivity columns are costly.

  5. 5. Clustered vs non-clustered index.

    How a senior interviewer scores this: Clustered defines physical row order (one per table); non-clustered is a separate lookup structure.

  6. 6. Walk through normalisation to 3NF — and when would you denormalise?

    How a senior interviewer scores this: Explains 1NF/2NF/3NF intuitively and denormalises deliberately for read performance.

  7. 7. When do you use a CTE vs a subquery vs a JOIN?

    How a senior interviewer scores this: CTEs for readability/recursion; understands they're not always a performance win.

  8. 8. Explain window functions with ROW_NUMBER vs RANK vs DENSE_RANK.

    How a senior interviewer scores this: Knows how PARTITION BY works and how the three differ on ties.

  9. 9. DELETE vs TRUNCATE vs DROP.

    How a senior interviewer scores this: Row-level + logged vs fast reset vs schema removal; knows rollback and trigger implications.

  10. 10. What are the ACID properties?

    How a senior interviewer scores this: Atomicity, Consistency, Isolation, Durability — with a one-line real example of each.

  11. 11. Explain transaction isolation levels and a dirty read.

    How a senior interviewer scores this: Walks read-uncommitted to serializable and trades concurrency against anomalies.

  12. 12. UNION vs UNION ALL.

    How a senior interviewer scores this: UNION dedupes (and sorts, costing performance); UNION ALL keeps duplicates and is faster.

  13. 13. Primary key vs unique key vs foreign key.

    How a senior interviewer scores this: Uniqueness + not-null vs uniqueness-allowing-null vs referential integrity.

  14. 14. A query is slow in production — how do you diagnose it?

    How a senior interviewer scores this: Reads the EXPLAIN/EXECUTION plan, checks indexes, sargability, and row estimates.

  15. 15. How does NULL behave in comparisons and aggregates?

    How a senior interviewer scores this: NULL is unknown (use IS NULL); COUNT(col) skips NULLs while COUNT(*) doesn't.

  16. 16. What's the difference between GROUP BY and DISTINCT?

    How a senior interviewer scores this: DISTINCT dedupes rows; GROUP BY also enables aggregation per group.

How SQL answers are scored

Strong candidates aren't just correct — they're graded on five dimensions a real interviewer weighs: technical correctness, communication, problem-solving, depth, and culture fit. For SQL specifically, the fastest score jump is narrating your reasoning and trade-offs out loud before you write code. Each question above lists what the interviewer is actually listening for.

Free gets you ready. Pro gets you sharp.

Practising these SQL questions out loud is free — unlimited mock interviews, the full 8,675 real questions across 23 languages, and the AI Study Coach, no credit card. When you want real-pressure reps, Pro ($10/mo) adds live voice interviews with Zaheen, the AI coach who asks follow-ups, pushes back, and scores you like a real interviewer — plus unlimited sessions.

See what Pro adds → $10/mo

7-day money-back guarantee · cancel anytime

SQL interview FAQ

What level are these SQL interview questions for?

From analyst screens to senior data and backend loops. Early rounds cover joins and aggregation; senior rounds add window functions, indexing strategy, and query tuning. The live query round is where most candidates are decided.

How should I prepare for a SQL interview in 2026?

Write queries by hand, not just in an IDE with autocomplete. Practise window functions and the second-highest-salary class of problems out loud, and be ready to read an execution plan and explain a fix.

Do SQL interviews focus on performance?

Increasingly, yes. Beyond writing correct queries, expect questions on indexing, sargability, and diagnosing a slow query via EXPLAIN. Knowing why a query is slow now matters as much as getting the right result.

More interview question guides