---
title: "SQL Interview Questions (2026): By Level, With Model Answers"
url: https://weworkworldwide.com/sql-developer-interview-questions/
description: "SQL interview questions for junior, mid and senior developers — joins, indexing, transactions and query optimisation — with model answers and the red flags to watch."
date: 2026-07-04T15:29:02+00:00
source: https://weworkworldwide.com/llms.txt
---

# SQL Interview Questions (2026): By Level, With Model Answers

How to use this

Almost every backend role touches SQL, and almost every performance fire starts there. These questions separate people who write queries from people who understand them.

Hiring a SQL developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.

## Junior SQL interview questions

0–2 years

Query fundamentals.

### What are the different types of JOIN?

What a strong answer covers

INNER returns matching rows; LEFT/RIGHT keep all rows from one side with NULLs for non-matches; FULL keeps both; CROSS is a Cartesian product.

Red flag

Only knows INNER JOIN and is unsure what LEFT does.

### What is the difference between `WHERE` and `HAVING`?

What a strong answer covers

`WHERE` filters rows before grouping; `HAVING` filters after aggregation.

Red flag

Tries to use an aggregate in `WHERE`.

### What does `GROUP BY` do?

What a strong answer covers

Collapses rows sharing the grouped columns so aggregates (COUNT, SUM, AVG) are computed per group.

Red flag

Selects non-aggregated, non-grouped columns and expects it to work.

### What is a primary key vs a foreign key?

What a strong answer covers

A primary key uniquely identifies a row; a foreign key references a primary key elsewhere, enforcing referential integrity.

Red flag

Confuses the two or thinks a table can have many primary keys.

### What is the difference between `UNION` and `UNION ALL`?

What a strong answer covers

Both combine result sets; `UNION` removes duplicates (and sorts to do so), `UNION ALL` keeps them and is faster.

Red flag

Always uses `UNION` unaware of the dedup cost.

### How do `NULL`s behave in comparisons?

What a strong answer covers

`NULL` is unknown, so `= NULL` is never true; you must use `IS NULL`, and NULLs affect aggregates and joins.

Red flag

Compares with `= NULL` and expects matches.

### What is the difference between `DELETE`, `TRUNCATE` and `DROP`?

What a strong answer covers

DELETE removes rows (logged, filterable); TRUNCATE quickly empties a table; DROP removes the table entirely.

Red flag

Thinks TRUNCATE can use a WHERE clause.

### What is the difference between `CHAR` and `VARCHAR`?

What a strong answer covers

CHAR is fixed length and padded; VARCHAR is variable length. They pick based on data shape.

Red flag

No idea there’s a storage difference.

## Mid-level SQL interview questions

2–5 years

Indexing, subqueries and transactions.

### How does an index speed up queries, and what is the cost?

What a strong answer covers

It gives fast lookups (typically a B-tree) instead of a full scan, at the cost of extra storage and slower writes; the wrong indexes hurt.

Red flag

Thinks indexes are free and adds one per column.

### What is a composite index and does column order matter?

What a strong answer covers

An index on multiple columns; order matters because it can only be used left-to-right (the leftmost-prefix rule).

Red flag

Assumes column order is irrelevant.

### What is the N+1 query problem?

What a strong answer covers

Running one query per row of a previous result instead of a single join or batched query, causing many round-trips; common with lazy ORMs.

Red flag

Has never heard of it despite writing ORM code.

### What are ACID properties?

What a strong answer covers

Atomicity, Consistency, Isolation, Durability — the guarantees a transaction provides. They can give a concrete example of each.

Red flag

Recites the acronym but can’t explain isolation.

### What is the difference between a correlated and a non-correlated subquery?

What a strong answer covers

A non-correlated subquery runs once; a correlated one references the outer query and runs per outer row, which can be slow.

Red flag

Writes correlated subqueries unaware of the performance cost.

### When do you use a `WITH` (CTE) vs a subquery?

What a strong answer covers

CTEs improve readability and enable recursion; they are otherwise similar, though materialisation behaviour varies by engine.

Red flag

Never uses CTEs and nests subqueries deeply.

### What are transaction isolation levels?

What a strong answer covers

Read Uncommitted, Read Committed, Repeatable Read and Serializable, trading concurrency against anomalies like dirty and phantom reads.

Red flag

Unaware isolation levels exist.

### What is a deadlock and how do you avoid one?

What a strong answer covers

Two transactions each waiting on locks the other holds; you reduce them by consistent lock ordering, short transactions and appropriate indexing.

Red flag

No concept of lock ordering.

## Senior SQL interview questions

5+ years

Optimisation and modelling.

### How do you diagnose a slow query?

What a strong answer covers

Read the `EXPLAIN`/execution plan for scans vs index use, check statistics and cardinality estimates, and look at joins and filters that can’t use an index.

Red flag

Rewrites queries randomly without reading a plan.

### What is normalisation and when do you denormalise?

What a strong answer covers

Organising data to remove redundancy (up to 3NF); you denormalise deliberately for read performance, accepting update complexity.

Red flag

Denormalises by default with no reason.

### What is a covering index?

What a strong answer covers

An index that contains all columns a query needs, so the engine answers from the index without touching the table.

Red flag

Never heard of index-only scans.

### How do window functions differ from `GROUP BY`?

What a strong answer covers

Window functions compute across a set of rows while keeping each row (ranking, running totals), unlike GROUP BY which collapses rows.

Red flag

Emulates running totals with slow self-joins.

### How do you handle very large tables?

What a strong answer covers

Partitioning, appropriate indexing, archiving cold data, batched writes, and avoiding full scans; sometimes read replicas.

Red flag

Runs unbounded queries against a huge table.

### What causes index bloat or an unused index?

What a strong answer covers

Low-selectivity columns, functions on indexed columns preventing use, and redundant indexes; monitoring usage stats helps prune them.

Red flag

Assumes every index they added is being used.

### How do you keep a schema evolving safely in production?

What a strong answer covers

Backward-compatible migrations, adding columns before backfilling, avoiding long locks, and expand/contract patterns for renames.

Red flag

Runs a blocking `ALTER` on a huge live table at peak.

### When is a relational database the wrong choice?

What a strong answer covers

When access is purely key-value, document-shaped, or needs extreme horizontal scale with simple queries; they can justify the tradeoff either way.

Red flag

Treats relational or NoSQL as universally superior.

**Skip the screening entirely.**We vet SQL engineers so you don’t have to — embed one in your team, or have us build it.

[Hire SQL developers](https://weworkworldwide.com/outstaffing/)[Compare us](https://weworkworldwide.com/compare/)

Build and score a full interview with our free [interview scorecard tool](https://weworkworldwide.com/developer-interview-scorecard/), browse the [full question hub](https://weworkworldwide.com/interview-questions/), or see [how we interview engineers](https://weworkworldwide.com/how-we-interview-engineers/).
