SQL Test Questions for Testers: 15 MCQs and 5 Backend Testing Queries

Most testing interviews in India now include an SQL test, whether the role is functional, backend or ETL testing. These SQL test questions cover the multiple-choice round and the “write a query” round, using examples testers meet every day. Try each one before opening the answer.

SQL Multiple Choice Questions (Q1–Q15)

Q1. Which clause filters groups after aggregation?

  • A. WHERE
  • B. HAVING
  • C. ORDER BY
  • D. GROUP BY
Show answer
Answer: B. HAVING filters after GROUP BY.

Q2. Which join returns all rows from the left table?

  • A. INNER JOIN
  • B. LEFT JOIN
  • C. CROSS JOIN
  • D. SELF JOIN
Show answer
Answer: B. Unmatched right-side columns become NULL.

Q3. COUNT(column) vs COUNT(*):

  • A. They are always equal
  • B. COUNT(column) ignores NULLs
  • C. COUNT(*) ignores NULLs
  • D. COUNT(column) counts duplicates once
Show answer
Answer: B. Useful for null checks.

Q4. Which finds rows in A that are not in B (Oracle)?

  • A. UNION
  • B. INTERSECT
  • C. MINUS
  • D. JOIN
Show answer
Answer: C. EXCEPT in SQL Server/PostgreSQL.

Q5. WHERE col = NULL returns:

  • A. NULL rows
  • B. No rows
  • C. All rows
  • D. An error always
Show answer
Answer: B. Use IS NULL.

Q6. Which removes duplicate rows from a result?

  • A. UNIQUE
  • B. DISTINCT
  • C. DELETE
  • D. TRIM
Show answer
Answer: B.

Q7. UNION vs UNION ALL:

  • A. UNION keeps duplicates
  • B. UNION ALL removes duplicates
  • C. UNION removes duplicates
  • D. They are the same
Show answer
Answer: C. UNION ALL is faster and keeps duplicates.

Q8. Which constraint prevents duplicate values?

  • A. NOT NULL
  • B. CHECK
  • C. UNIQUE
  • D. DEFAULT
Show answer
Answer: C.

Q9. A foreign key ensures:

  • A. Values are unique
  • B. Values exist in the parent table
  • C. Values are not null
  • D. Values are indexed
Show answer
Answer: B. Referential integrity.

Q10. Which is a DML command?

  • A. CREATE
  • B. ALTER
  • C. UPDATE
  • D. DROP
Show answer
Answer: C. DML changes data; DDL changes structure.

Q11. Which function returns the first non-NULL value?

  • A. NVL only
  • B. COALESCE
  • C. ISNULL only
  • D. NULLIF
Show answer
Answer: B. COALESCE is standard SQL.

Q12. ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) is used to:

  • A. Count rows
  • B. Pick the latest row per id
  • C. Delete rows
  • D. Join tables
Show answer
Answer: B. Common in duplicate handling.

Q13. TRUNCATE vs DELETE:

  • A. TRUNCATE can use WHERE
  • B. DELETE removes table structure
  • C. TRUNCATE removes all rows quickly
  • D. They are identical
Show answer
Answer: C.

Q14. Which query finds duplicate emails?

  • A. GROUP BY email HAVING COUNT(*) > 1
  • B. WHERE COUNT(email) > 1
  • C. DISTINCT email
  • D. ORDER BY email
Show answer
Answer: A.

Q15. A primary key can contain:

  • A. NULLs
  • B. Duplicates
  • C. Neither NULLs nor duplicates
  • D. Only numbers
Show answer
Answer: C.

SQL Queries for Backend Testing

Functional testers use these after performing an action in the UI, to confirm the database changed correctly.

1. Verify a new user saved after sign-up

SQL
SELECT user_id, email, status, created_at
FROM users
WHERE email = 'test.user@example.com';

2. Check an order total matches its line items

SQL
SELECT o.order_id, o.total_amount, SUM(l.qty * l.price) AS line_total
FROM orders o JOIN order_lines l ON l.order_id = o.order_id
GROUP BY o.order_id, o.total_amount
HAVING o.total_amount <> SUM(l.qty * l.price);

3. Orphan records (child without parent)

SQL
SELECT l.order_id FROM order_lines l
LEFT JOIN orders o ON o.order_id = l.order_id
WHERE o.order_id IS NULL;

4. Status changed after cancellation in the UI

SQL
SELECT order_id, status, updated_at FROM orders WHERE order_id = 1042;

5. Soft-deleted rows hidden from active lists

SQL
SELECT COUNT(*) FROM customers WHERE is_deleted = 1 AND is_active = 1;   -- expect 0

Score Yourself

MCQ scoreNext step
13–15Move on to SQL query interview questions for ETL testing
9–12Revise joins and NULL handling with SQL joins
Below 9Start with SQL for testers

Practise Under Interview Conditions

Reading answers is not the same as answering under time pressure. ETL Testing Interview Questions & Answers – Practice Tests gives you 500+ questions with detailed explanations, from fresher to experienced level, including Python and ETL automation questions alongside SQL, data warehouse and scenario-based rounds. Attempt a test, review every explanation, and retake until you are consistently above 80%.

  • Timed practice tests that feel like a real screening round
  • Python, automation, SQL and scenario questions in one place
  • Detailed answers, so each wrong attempt teaches you something
  • Lifetime access and Udemy’s refund policy

Prepare for your ETL testing interview: top 50 questions · in-depth answers · for experienced (3–5 years) · for 10 years experience · SQL query questions · scenario-based questions · data warehouse questions · questions for freshers · free mock test · database testing questions · Python ETL testing questions · Informatica questions · SQL questions for freshers · DBMS questions · data validation questions · service-company questions · ETL automation testing questions · Python test questions · Big 4 (Deloitte, PwC, EY, KPMG) · tough questions · self introduction

Frequently Asked Questions

What SQL questions are asked in testing interviews?

Joins, GROUP BY and HAVING, NULL handling, finding duplicates, MINUS/EXCEPT, constraints, and writing queries to verify data after a UI action.

How much SQL does a functional tester need?

Enough to read and verify data: SELECT with WHERE, joins, GROUP BY, and checks for duplicates, NULLs and orphan records.

Are these real company SQL test questions?

No. They are original practice questions in the style of common online tests.

Asim Noaman Lodhi
Written by

Asim Noaman Lodhi

Certified Google Partner · QA Consultant · 12+ Years IT

QA consultant specializing in ETL testing and data quality. Trained 913+ students to transition into data testing roles through hands-on, real-world instruction.

4.5 Rating 913+ Students Google Partner 79 Lectures

Pass the SQL Round With Confidence

500+ ETL testing interview questions with detailed answers, from fresher to experienced level.

Practice 500+ Questions