Stop 15 · Interview PreparationAutomation & Technical · 3/3

SQL Questions for QA

Part of the QA Testing Roadmap

In short

Almost every QA interview has a few SQL questions, even for automation roles. Testers use SQL to check data the UI can't show, so expect to write queries live.

Live SQL writing exercises testing Phase 5's database testing fluency — a near-universal component of QA interviews, even at automation-focused roles.

The purple blob pulls open a drawer of a wooden library card catalogue and flips through cards.

Think of it like this

The library card catalogue

In an old library, you don't walk every shelf to find a book. You open the right drawer of the card catalogue and pull exactly the cards you need. SQL is that catalogue for your app's data.

Watch it happen

Finding duplicate emails, the GROUP BY way

riya@x.in
0
aman@x.in
1
riya@x.in
2
neha@x.in
3
aman@x.in
4

1/5A classic interview question: the users table should have unique emails. Find any duplicates.

The big ideas

What you need to know

JOINs

Know INNER vs LEFT JOIN. LEFT JOIN with WHERE ... IS NULL finds records with no match, a favourite question.

GROUP BY and HAVING

WHERE filters rows before grouping. HAVING filters groups after. Expect a question on the difference.

Classic puzzles

Second-highest salary, duplicates, count per category, latest order per customer. Practise each once.

Why testers use SQL

Verify the UI saved the right data, set up test data, and find broken records the UI hides.

See it in code

Walk through the code

sql
1-- 1. Find duplicate emails2SELECT email, COUNT(*) AS times3FROM users4GROUP BY email5HAVING COUNT(*) > 1;6 7-- 2. Orders with no matching customer (broken data)8SELECT o.id9FROM orders o10LEFT JOIN customers c ON c.id = o.customer_id11WHERE c.id IS NULL;

1/2Group users by email and keep only emails that appear more than once.

Two queries that come up again and again. Practise typing them without looking.

Save yourself the pain

Common mistakes

Oops

Using WHERE COUNT(*) > 1.

Do this instead

Aggregates are filtered with HAVING, after GROUP BY. WHERE runs before grouping.

Oops

Using INNER JOIN to find orders with missing customers.

Do this instead

INNER JOIN drops unmatched rows. Use LEFT JOIN and check for NULL.

Your mission

Six classic queries

~40 min

Quick check

Which clause filters groups after a GROUP BY?

Go deeper

  1. 1Practice writing SQL queries on a sample database under light time pressure.
  2. 2Review JOINs specifically — the most commonly tested SQL skill in QA interviews.
  3. 3Talk through your query logic out loud before writing it, even in practice.

More automation & technical at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge