๐Ÿ  Home๐ŸŽฎ Play Game Modes๐Ÿ† Daily Challenge๐Ÿค– AI Generatorโ„น๏ธ About Us๐Ÿ“ Quiz Blog๐Ÿ“ฌ Contact Us
๐Ÿ Home
Blog
๐Ÿ“SQL
๐Ÿ—„๏ธ
SQL

SQL Quiz: 20 Questions for Interview Prep (2026)

๐Ÿ“… July 15, 2026โฑ 11 min readโœ๏ธ QuizOxa Editorial Team

SQL is the language of data, and it shows up in almost every backend, data-analyst, and data-engineering interview. The good news is that a solid grasp of a few core concepts, queries, JOINs, keys, and aggregation, covers the majority of questions you will face.

Below are 20 SQL quiz questions with clear answers and short explanations. They apply to standard SQL, so they hold true across MySQL, PostgreSQL, SQL Server, and SQLite with only minor syntax differences.

SQL Basics & Queries (1โ€“10)

Q1. What does SQL stand for?

โœ… Answer: Structured Query Language

๐Ÿ’ก SQL is the standard language for storing, retrieving, and managing data in a relational database.

Q2. Which statement is used to retrieve data from a table?

โœ… Answer: SELECT

๐Ÿ’ก SELECT reads data. For example, `SELECT name FROM users;` returns the name column from the users table.

Q3. Which clause filters rows based on a condition?

โœ… Answer: WHERE

๐Ÿ’ก WHERE keeps only rows that meet a condition, e.g. `WHERE age > 18`. It filters rows before any grouping.

Q4. How do you sort query results?

โœ… Answer: ORDER BY

๐Ÿ’ก ORDER BY sorts results ascending by default; add DESC for descending, e.g. `ORDER BY created_at DESC`.

Q5. Which keyword removes duplicate rows from results?

โœ… Answer: DISTINCT

๐Ÿ’ก `SELECT DISTINCT country FROM users;` returns each country only once, removing duplicates.

Q6. Which statement adds a new row to a table?

โœ… Answer: INSERT INTO

๐Ÿ’ก `INSERT INTO users (name) VALUES ('Sara');` adds a new record to the users table.

Q7. Which statement modifies existing rows?

โœ… Answer: UPDATE

๐Ÿ’ก UPDATE changes data in existing rows. Always pair it with a WHERE clause, or every row will be updated.

Q8. Which statement removes rows from a table?

โœ… Answer: DELETE

๐Ÿ’ก `DELETE FROM users WHERE id = 5;` removes matching rows. Without WHERE, it deletes all rows.

Q9. What does the LIMIT clause do?

โœ… Answer: Restricts the number of rows returned

๐Ÿ’ก `SELECT * FROM users LIMIT 10;` returns at most 10 rows. SQL Server uses TOP instead of LIMIT.

Q10. Which operator checks whether a value is within a range?

โœ… Answer: BETWEEN

๐Ÿ’ก `WHERE age BETWEEN 18 AND 30` matches values from 18 to 30 inclusive.

๐Ÿ’ก Interview tip

When writing an UPDATE or DELETE, mention that you would run the WHERE condition as a SELECT first. It shows caution and prevents accidentally changing every row.

Keys, JOINs & Aggregation (11โ€“20)

Q1. What is a PRIMARY KEY?

โœ… Answer: A column (or set of columns) that uniquely identifies each row

๐Ÿ’ก A primary key must be unique and cannot be NULL. Each table can have only one primary key.

Q2. What is a FOREIGN KEY?

โœ… Answer: A column that references the primary key of another table

๐Ÿ’ก Foreign keys enforce referential integrity, linking related tables (e.g. an orders table referencing a customers table).

Q3. What does an INNER JOIN return?

โœ… Answer: Only rows that have matching values in both tables

๐Ÿ’ก An INNER JOIN combines rows from two tables where the join condition is met, dropping unmatched rows.

Q4. What is the difference between INNER JOIN and LEFT JOIN?

โœ… Answer: LEFT JOIN returns all rows from the left table plus matches from the right (NULLs where none match)

๐Ÿ’ก INNER JOIN keeps only matched rows; LEFT (OUTER) JOIN keeps every left-table row even when there is no match on the right.

Q5. What does the GROUP BY clause do?

โœ… Answer: Groups rows that share a value so aggregate functions can be applied per group

๐Ÿ’ก `SELECT country, COUNT(*) FROM users GROUP BY country;` counts users per country.

Q6. What is the difference between WHERE and HAVING?

โœ… Answer: WHERE filters rows before grouping; HAVING filters groups after aggregation

๐Ÿ’ก You cannot use an aggregate like COUNT() in WHERE, but you can in HAVING, e.g. `HAVING COUNT(*) > 5`.

Q7. Name the common SQL aggregate functions.

โœ… Answer: COUNT, SUM, AVG, MIN, and MAX

๐Ÿ’ก These summarise data across rows, e.g. `AVG(salary)` returns the average salary in a group.

Q8. What is an index and why is it used?

โœ… Answer: A data structure that speeds up row lookups

๐Ÿ’ก Indexes make reads faster but slightly slow down writes and use extra storage. They are ideal on columns used in WHERE and JOIN conditions.

Q9. What is database normalization?

โœ… Answer: Organising tables to reduce data redundancy and improve integrity

๐Ÿ’ก Normalization splits data into related tables (e.g. 1NF, 2NF, 3NF) so the same information is not stored in multiple places.

Q10. What is the difference between DELETE, TRUNCATE, and DROP?

โœ… Answer: DELETE removes selected rows; TRUNCATE removes all rows quickly; DROP removes the entire table

๐Ÿ’ก DELETE can use WHERE and is logged row by row. TRUNCATE clears all rows fast with no WHERE. DROP deletes the table structure itself.

โš ๏ธ Common mistake

Running UPDATE or DELETE without a WHERE clause affects every row in the table. Double-check your condition before executing.

Frequently Asked Questions

Are these SQL questions good for interviews?

Yes. Queries, JOINs, keys, GROUP BY vs HAVING, indexes, and normalization are among the most commonly asked SQL topics in data-analyst, backend, and data-engineering interviews.

Do these questions apply to MySQL and PostgreSQL?

Almost entirely. They cover standard SQL, which works across MySQL, PostgreSQL, SQL Server, and SQLite. Only small syntax details differ, such as LIMIT (MySQL/PostgreSQL) versus TOP (SQL Server).

What is the best way to practise SQL?

Create a small sample database and write real queries, or use a free online SQL sandbox. Practising by actually running queries cements the concepts far better than reading alone.

๐ŸŽฏ Play the Computer Science Quiz

๐ŸŽฏTry These Quizzes

๐Ÿ–ฅ๏ธ
Computer Science Questions
๐Ÿ“50 questions
๐Ÿ’ป
Technology Questions
๐Ÿ“50 questions
๐Ÿค–
AI Questions
๐Ÿ“50 questions

๐Ÿ“šRelated Articles

1
๐Ÿ
Python Quiz: 100 MCQ Questions for Interview Prep
Core Python multiple-choice questions for coding interviews.
2
๐ŸŸจ
JavaScript Quiz: 20 Questions Every Developer Should Know
Closures, the event loop, promises, and type coercion.
3
๐Ÿ’ป
50 Tech Trivia Questions and Answers
Programming, hardware, networks, AI, and IT history.
โœ๏ธ
QuizOxa Editorial Team

Questions are checked against standard ANSI SQL behaviour and common database documentation (MySQL, PostgreSQL).