FREE PDF · 10 PAGES · 2026 EDITION

Top 50 SQL Interview Questions

The questions data teams actually ask, with short, clear answers and SQL examples you can practise today. Written by a Senior Data Engineer who has prepared 100+ students for interviews.

  • SQL basics10
  • Joins8
  • Aggregation and grouping6
  • Subqueries and CTEs6
  • Window functions8
  • Data modelling and design6
  • Performance6
Data analystsData engineersBI developersFresh graduates
Cover of the Top 50 SQL Interview Questions guide

Get the free PDF

Instant download. No spam, ever.

Your details stay private and are only used by Hikmat Ullah.

A sneak peek

Three of the 50 questions inside. Every answer is short enough to remember and clear enough to explain in an interview.

Q1

What is the difference between WHERE and HAVING?

WHERE filters rows before grouping. HAVING filters groups after GROUP BY, so it can use aggregates like COUNT or SUM.

SELECT customer_id, SUM(amount) AS total
FROM orders
WHERE status = 'paid'
GROUP BY customer_id
HAVING SUM(amount) > 1000;
Q12

How do you find customers who have never placed an order?

Use a LEFT JOIN and keep the rows where the right side is NULL, or use NOT EXISTS.

SELECT c.customer_id, c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.customer_id
WHERE o.order_id IS NULL;
Q32

What is the difference between ROW_NUMBER, RANK and DENSE_RANK?

For ties: ROW_NUMBER gives 1, 2, 3. RANK gives 1, 1, 3 (skips). DENSE_RANK gives 1, 1, 2 (no gaps).

Prefer to practise with a mentor?

I teach SQL one-to-one with real projects, mock interviews and job placement support.

SQL Developer courseBook a free callWhatsApp