Practice these MCQs to strengthen your SQL knowledge and prepare confidently for job interviews or certification exams.
Whether you’re aiming to become a database expert or mastering queries for data analysis and application development — you’re in the right place.
50 SQL MCQs covering everything from SELECT statements, joins, subqueries, indexing, functions, constraints, and transactions — complete with answers to help you test and reinforce your understanding, no guesswork involved.
✅ SQL Query-Based MCQs (With Code Snippets)
1. What will be the output of the following query?
SELECT LENGTH(‘SQL Quiz’);
a) 6
b) 7
c) 8
d) 9
Answer: c) 8
2. What does this query return?
SELECT COUNT(*) FROM Employees WHERE Department = ‘HR’;
a) Number of HR employees
b) List of HR employees
c) HR department names
d) Error
Answer: a) Number of HR employees
3. Which keyword is used to eliminate duplicate rows in a query result?
a) NO DUPLICATE
b) UNIQUE
c) DISTINCT
d) DIFFERENT
Answer: c) DISTINCT
4. What will this query return if table has values (10, 20, 30)?
SELECT AVG(Salary) FROM Employees;
a) 20
b) 60
c) 30
d) NULL
Answer: a) 20
5. What does the following SQL query do?
SELECT * FROM Students WHERE Marks BETWEEN 50 AND 80;
a) Selects students with marks > 80
b) Selects students with marks < 50
c) Selects students with marks from 50 to 80
d) Syntax error
Answer: c) Selects students with marks from 50 to 80
6. What does this query return?
SELECT UPPER(‘gyansetu’);
a) gyansetu
b) GYansetu
c) GYANSETU
d) Gyansetu
Answer: c) GYANSETU
7. Which operator is used for pattern matching in SQL?
a) =
b) MATCH
c) LIKE
d) COMPARE
Answer: c) LIKE
8. What is the result of this query?
SELECT 15 % 4;
a) 3
b) 4
c) 2
d) 1
Answer: a) 3
From Zero to SQL Hero – Start Your Data Journey Today
9. What will this query do?
SELECT * FROM Orders ORDER BY OrderDate DESC;
a) Returns data sorted by newest to oldest
b) Returns data sorted by oldest to newest
c) Deletes old orders
d) None of the above
Answer: a) Returns data sorted by newest to oldest
10. What will the output be?
SELECT ROUND(123.4567, 2);
a) 123.45
b) 123.46
c) 123.44
d) 123.00
Answer: b) 123.46
11. Which clause is used to sort query results?
a) SORT BY
b) GROUP BY
c) ORDER BY
d) ARRANGE BY
Answer: c) ORDER BY
12. Which command deletes all rows from a table without logging each deletion?
a) REMOVE
b) TRUNCATE
c) DELETE
d) DROP
Answer: b) TRUNCATE
13. What does this query do?
SELECT * FROM Products WHERE ProductName LIKE ‘L%’;
a) Finds products that contain L
b) Finds products ending with L
c) Finds products starting with L
d) Syntax error
Answer: c) Finds products starting with L
14. Which operator checks if a value is within a range?
a) BETWEEN
b) IN
c) RANGE
d) WITHIN
Answer: a) BETWEEN
15. What is the output of this query if table contains 3 rows?
SELECT COUNT(DISTINCT Country) FROM Customers;
a) 3
b) 1
c) Number of unique countries
d) Syntax error
Answer: c) Number of unique countries
16. What is the output of the query below?
SELECT COALESCE(NULL, NULL, 'Gyansetu', 'SQL');
a) NULL
b) SQL
c) Gyansetu
d) NULLGyansetu
Answer: c) Gyansetu
17. Which clause is used to filter groups?
a) WHERE
b) FILTER
c) HAVING
d) GROUP BY
Answer: c) HAVING
18. What does this query return?
SELECT SUBSTRING(‘DataScience’, 5, 3);
a) Data
b) Sci
c) aSc
d) Scie
Answer: c) aSc
19. What will this query do?
SELECT NOW();
a) Returns current date only
b) Returns current time only
c) Returns current date and time
d) Error
Answer: c) Returns current date and time
20. Which command removes a table structure?
a) DELETE
b) ERASE
c) REMOVE
d) DROP
Answer: d) DROP
21. What does this query return?
SELECT ABS(-50);
a) -50
b) 0
c) 50
d) Error
Answer: c) 50
22. What is the purpose of this query?
SELECT * FROM Employees WHERE Salary IS NULL;
a) Fetch employees with 0 salary
b) Fetch employees with no salary data
c) Fetch all employees
d) Error
Answer: b) Fetch employees with no salary data
23. What will the following query return?
SELECT CONCAT(‘Data’, ‘Science’);
a) Data Science
b) DataScience
c) ‘Data”Science’
d) Error
Answer: b) DataScience
24. To check for NULL values, use:
a) = NULL
b) IS NULL
c) == NULL
d) EQUALS NULL
Answer: b) IS NULL
25. What is the output of the query?
SELECT POWER(2, 4);
a) 6
b) 8
c) 16
d) 4
Answer: c) 16
Speak the Language of Databases – Learn SQL.
26. What does this query do?
SELECT * FROM Students WHERE Name IN (‘Alice’, ‘Bob’);
a) Selects students whose names are not Alice or Bob
b) Selects students named Alice or Bob
c) Selects all students
d) Syntax error
Answer: b) Selects students named Alice or Bob
27. Which type of JOIN returns all records when there is a match in either table?
a) INNER JOIN
b) OUTER JOIN
c) LEFT JOIN
d) FULL JOIN
Answer: d) FULL JOIN
28. What will this query return?
SELECT TRIM(‘ SQL ‘);
a) “SQL”
b) ” SQL “
c) ” SQL “
d) “SQL “
Answer: a) “SQL”
29. What is the output of this query?
SELECT DAY(‘2025-06-15’);
a) 6
b) 15
c) 2025
d) June
Answer: b) 15
30. Which JOIN returns only matching rows from both tables?
a) LEFT JOIN
b) RIGHT JOIN
c) FULL JOIN
d) INNER JOIN
Answer: d) INNER JOIN
31. What does this query return if Age column has values 20, 22, 25, 28?
SELECT MAX(Age) FROM Users;
a) 20
b) 28
c) 25
d) NULL
Answer: b) 28
32. What will this query output?
SELECT MOD(17, 5);
a) 3
b) 2
c) 1
d) 4
Answer: b) 2
33. What does the following query do?
SELECT DISTINCT City FROM Customers;
a) Lists all cities from Customers
b) Lists unique cities only
c) Deletes duplicate cities
d) Shows customer count per city
Answer: b) Lists unique cities only
34. Which of the following is NOT a valid SQL function?
a) AVG()
b) COUNT()
c) TOTAL()
d) SUM()
Answer: c) TOTAL()
35. Which operator is used to compare a value to a list of values?
a) WITH
b) BETWEEN
c) IN
d) ANY
Answer: c) IN
36. What is the result of this query?
SELECT FLOOR(5.9);
a) 5.0
b) 6
c) 5
d) Error
Answer: c) 5
37. What will this query return?
SELECT IFNULL(NULL, ‘SQL’);
a) NULL
b) SQL
c) 0
d) Error
Answer: b) SQL
38. What does this query do?
SELECT * FROM Orders WHERE Quantity > 5 AND Quantity < 10;
a) Returns rows where quantity is 5
b) Returns rows with quantity 5 to 10
c) Returns rows with quantity between 6 and 9
d) Returns all rows
Answer: c) Returns rows with quantity between 6 and 9
39. What is the output of this query?
SELECT REPLACE(‘Data Science’, ‘ ‘, ‘-‘);
a) Data Science
b) Data-Science
c) Data–Science
d) Error
Answer: b) Data-Science
40. Which command provides the structure of a table?
a) LIST
b) SHOW STRUCTURE
c) DESCRIBE
d) DETAILS
Answer: c) DESCRIBE
41. Which SQL clause is used to set an alias for a column or table?
a) NAMED AS
b) LABEL
c) AS
d) TITLE
Answer: c) AS
42. What will this query return?
SELECT CHAR_LENGTH(‘SQL Programming’);
a) 15
b) 14
c) 16
d) 13
Answer: a) 15
43. What does the query return?
SELECT YEAR(‘2023-12-25’);
a) 12
b) 2023
c) December
d) 25
Answer: b) 2023
44. What does this query do?
SELECT * FROM Employees LIMIT 5 OFFSET 10;
a) Returns first 5 rows
b) Skips first 5 rows, returns next 10
c) Skips first 10 rows, returns next 5
d) Shows last 5 rows only
Answer: c) Skips first 10 rows, returns next 5
45. What does this query return?
SELECT LOWER(‘SQL QUIZ’);
a) sql quiz
b) SQL QUIZ
c) Sql Quiz
d) sql_quiz
Answer: a) sql quiz
46. What will this query return?
SELECT REPEAT(‘SQL’, 3);
a) SQL SQL SQL
b) SQL3
c) SQLSQLSQL
d) Error
Answer: c) SQLSQLSQL
47. What does the following query return?
SELECT INSTR(‘Database’, ‘base’);
a) 1
b) 5
c) 4
d) 0
Answer: b) 5
48. What is the result of this query?
SELECT LPAD(’75’, 4, ‘0’);
a) 0075
b) 7500
c) 75
d) 0750
Answer: a) 0075
49. What does this query return?
SELECT RIGHT(‘Gyansetu’, 3);
a) anu
b) setu
c) utu
d) etu
Answer: d) etu
50. What is the result of this query?
SELECT DAYNAME(‘2025-06-15’);
a) Monday
b) Saturday
c) Sunday
d) Friday
Answer: c) Sunday
Join the Data Revolution with SQL Skills
51. What does this query do?
SELECT COUNT(*) FROM Employees WHERE Department IN (‘HR’, ‘Finance’);
a) Lists HR and Finance departments
b) Returns number of employees in HR or Finance
c) Lists employees
d) Error
Answer: b) Returns number of employees in HR or Finance
52. What will the following query return?
SELECT LENGTH(REPLACE(‘SQL World’, ‘ ‘, ”));
a) 8
b) 9
c) 10
d) 11
Answer: a) 8
53. What does this query return?
SELECT FIND_IN_SET(‘apple’, ‘banana,apple,grapes’);
a) 1
b) 2
c) 3
d) 0
Answer: b) 2
54. What is the output of this query?
SELECT CONCAT(‘AI’, NULL);
a) AI
b) NULL
c) AI NULL
d) Error
Answer: b) NULL
55. What is the result of the query?
SELECT ROUND(345.678, -2);
a) 300
b) 340
c) 400
d) 345.67
Answer: c) 400
56. What does the following query do?
SELECT DISTINCT LENGTH(Name) FROM Students;
a) Returns total names
b) Returns unique name lengths
c) Returns only shortest name
d) Returns longest name
Answer: b) Returns unique name lengths
57. What does this query return?
SELECT LTRIM(‘ SQL’);
a) SQL
b) SQL
c) SQL
d) Error
Answer: a) SQL
58. What is the output of this query?
SELECT CAST(‘2025-06-15’ AS DATE);
a) ‘2025/06/15’
b) 2025-06-15
c) June 15, 2025
d) Syntax error
Answer: b) 2025-06-15
59. What does the following query return?
SELECT YEAR(CURDATE());
a) 2023
b) 2024
c) 2025
d) Depends on system date
Answer: d) Depends on system date
60. What is the result of the query below?
SELECT LENGTH(‘SQL’) + LENGTH(‘Quiz’);
a) 6
b) 7
c) 8
d) 9
Answer: c) 8
Mastering these SQL MCQs is a valuable step toward building strong database management and querying skills.
If you’re ready to elevate your career with real-world SQL projects, practical query writing, and expert-led instruction, join our SQL course in Gurgaon at Gyansetu and become industry-ready in the field of data analytics and database development.