Which SQL statement is used to retrieve data from a database table?
SELECT ✅INSERTUPDATEDELETESELECT is the most fundamental SQL statement — it retrieves data from one or more tables. Basic syntax: SELECT column1, column2 FROM table_name WHERE condition;. Use SELECT * to retrieve all columns (avoid in production for performance). INSERT adds new rows, UPDATE modifies existing rows, and DELETE removes rows. SELECT is by far the most used SQL command.Which SQL clause is used to filter rows based on a specified condition?
ORDER BYWHERE ✅GROUP BYHAVINGWHERE filters rows BEFORE grouping. Example: SELECT * FROM employees WHERE salary > 50000;. Common operators: =, !=, >, <, BETWEEN, IN, LIKE, IS NULL. ORDER BY sorts results. GROUP BY groups rows for aggregation. HAVING filters AFTER grouping (used with aggregate functions). The SQL execution order: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.Which keyword is used with SELECT to return only unique (non-duplicate) values?
DISTINCT ✅UNIQUELIMITTOPSELECT DISTINCT column_name FROM table; returns only unique values, removing duplicates. Example: SELECT DISTINCT department FROM employees; lists each department once. UNIQUE is a constraint (not a SELECT keyword). LIMIT restricts the number of rows returned (MySQL/PostgreSQL). TOP does the same in SQL Server. DISTINCT is essential for data analysis and deduplication.Which SQL operator is used to search for a pattern in a text column — for example, finding all names that start with “J”?
INLIKE ✅BETWEENEXISTSLIKE performs pattern matching using wildcards: % (any number of characters) and _ (exactly one character). Examples: WHERE name LIKE 'J%' (starts with J), WHERE email LIKE '%@gmail.com' (Gmail addresses), WHERE code LIKE 'A_B' (3 characters starting with A, ending with B). IN checks membership in a list. BETWEEN checks a range. LIKE is essential for text searching.JOINs & Table Relationships
Combining Data from Multiple Tables
Which type of JOIN returns ONLY the rows that have matching values in BOTH tables?
INNER JOIN ✅LEFT JOINRIGHT JOINFULL OUTER JOININNER JOIN returns only rows with matching values in both tables — the intersection. LEFT JOIN returns all rows from the left table + matching rows from the right (NULL for non-matches). RIGHT JOIN is the opposite. FULL OUTER JOIN returns all rows from both tables (NULLs where no match). INNER JOIN is the default and most common JOIN type. JOINs are the #1 interview topic.An analyst wants to retrieve ALL customers, including those who have never placed an order. Which JOIN should they use between the customers and orders tables?
INNER JOINLEFT JOIN customers ON customers.id = orders.customer_id ✅RIGHT JOINCROSS JOINLEFT JOIN (or LEFT OUTER JOIN) returns ALL rows from the left table (customers) and matching rows from the right table (orders). Customers with no orders will appear with NULL in the order columns. INNER JOIN would exclude customers without orders. This is the most common real-world scenario — “show me all X, even if they don’t have related Y.” LEFT JOIN is the most tested JOIN in interviews.What is a PRIMARY KEY in a relational database?
orders.customer_id (FOREIGN KEY) → customers.id (PRIMARY KEY). This is how relational databases connect tables.Aggregation & GROUP BY
Summarizing & Analyzing Data
Which SQL query returns the total number of employees in each department?
SELECT department, COUNT(*) FROM employees GROUP BY department; ✅SELECT department, COUNT(*) FROM employees;SELECT COUNT(department) FROM employees;SELECT department, SUM(*) FROM employees GROUP BY department;GROUP BY groups rows with the same value and allows aggregate functions to calculate per-group results. COUNT(*) counts all rows in each group. The 5 aggregate functions: COUNT() (count rows), SUM() (total), AVG() (average), MIN() (minimum), MAX() (maximum). Rule: every non-aggregated column in SELECT must appear in GROUP BY.Which clause is used to filter groups AFTER aggregation — for example, showing only departments with more than 10 employees?
WHERE COUNT(*) > 10HAVING COUNT(*) > 10 ✅GROUP BY COUNT(*) > 10FILTER COUNT(*) > 10HAVING filters groups AFTER aggregation — it works with aggregate functions. WHERE filters individual rows BEFORE grouping and cannot use aggregate functions. This is one of the most common interview questions: “What’s the difference between WHERE and HAVING?” Answer: WHERE filters rows, HAVING filters groups. You CANNOT use WHERE COUNT(*) > 10 — it must be HAVING.What is the correct SQL execution order (logical processing order)?
FROM + JOINs (identify tables), (2) WHERE (filter rows), (3) GROUP BY (group rows), (4) HAVING (filter groups), (5) SELECT (choose columns), (6) ORDER BY (sort results), (7) LIMIT (restrict output). This is why you can’t use column aliases in WHERE (SELECT hasn’t executed yet) but CAN use them in ORDER BY. This order is fundamental to understanding SQL.DML, DDL & Subqueries
Modifying Data & Advanced Queries
Which SQL command is used to add a new row of data into a table?
INSERT INTO table_name VALUES (...) ✅UPDATE table_name SET ...ADD ROW INTO ...CREATE ROW ...INSERT INTO adds new rows. Two syntax options: INSERT INTO table (col1, col2) VALUES ('value1', 'value2'); (explicit columns — preferred) or INSERT INTO table VALUES ('v1', 'v2'); (all columns in order). DML (Data Manipulation Language) includes SELECT, INSERT, UPDATE, DELETE. DDL (Data Definition Language) includes CREATE, ALTER, DROP, TRUNCATE. Know the difference.What is the difference between DELETE and TRUNCATE in SQL?
DELETE is DML — it removes rows one by one, supports WHERE clause, fires triggers, and can be rolled back within a transaction. TRUNCATE is DDL — it removes ALL rows instantly, resets auto-increment, doesn’t fire triggers, and generally cannot be rolled back. DROP removes the entire table structure. Remember: DELETE = surgical removal, TRUNCATE = factory reset, DROP = demolition.Which query finds employees whose salary is higher than the company average salary?
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees); ✅SELECT * FROM employees WHERE salary > AVG(salary);SELECT * FROM employees HAVING salary > AVG(salary);SELECT * FROM employees ORDER BY AVG(salary);(SELECT AVG(salary) FROM employees) calculates the average first, then the outer query compares each employee’s salary against it. You CANNOT use aggregate functions directly in WHERE — that’s why option B fails. Subqueries can appear in WHERE, FROM (derived tables), SELECT (scalar subqueries), and HAVING clauses.What does NULL represent in SQL?
= NULL — you must use IS NULL or IS NOT NULL. NULL in any arithmetic operation returns NULL (e.g., 5 + NULL = NULL). Use COALESCE(column, default_value) to replace NULLs with a default. Understanding NULL behavior is critical for writing correct SQL queries.📋 SQL Command Categories
INSERT
UPDATE
DELETE
ALTER
DROP
TRUNCATE
REVOKE
(Permissions)
🔗 4 Types of JOINs
rows from both
matching right
matching left
from both
📊 5 Aggregate Functions
🔄 SQL Execution Order
💡 SQL Interview & Study Tips
🎯 Keep Practicing — More MCQs Available!
We update our question bank regularly to cover more SQL topics

Frequently Asked Questions
Basic SQL (SELECT, WHERE, JOINs, GROUP BY) can be learned in 2-4 weeks of consistent practice. Intermediate SQL (subqueries, window functions, CTEs) takes another 2-4 weeks. Advanced SQL (query optimization, indexing, database design) requires months of real-world experience. Most data analyst job requirements can be met with 1-2 months of focused learning.
Start with any standard SQL database — the core syntax is 90% the same across platforms. Popular choices: MySQL (most popular open-source, great for web), PostgreSQL (advanced features, enterprise-grade), SQLite (lightweight, great for learning), or SQL Server (Microsoft ecosystem). Learn standard SQL first, then learn platform-specific features as needed for your role.
Absolutely — SQL is the #1 most requested skill in data analyst, data scientist, backend developer, and BI analyst job postings. It has been the industry standard for 50+ years and shows no signs of declining. Even with NoSQL databases and AI tools, SQL remains essential because relational databases power the vast majority of business applications, data warehouses, and analytics platforms.
While there’s no single “SQL certification” like CompTIA or AWS, several vendor-specific options exist: Oracle Database SQL Certified Associate, Microsoft Azure Data Fundamentals (DP-900), and IBM Data Engineering Certificate. Additionally, many general certifications like CompTIA Data+, Google Data Analytics, and Power BI PL-300 heavily test SQL concepts. For most roles, demonstrating SQL skills through projects and assessments matters more than a specific SQL cert.

Leave a Comment