Last Updated On
Welcome to the SQL Quiz! This blog post features 25 multiple-choice questions that explore essential concepts of SQL.
1. Which of the following statement is true about views in SQL?
Select the best answer
a) We can delete but not insert rows in a view
b) We cannot insert and delete rows in a view
c) We can insert but not delete rows in a view
d) We can insert and delete rows in a view
2. Which SQL keyword is used to sort the data returned by a SELECT statement?
Choose one option
a) Group
b) Order
c) Group By
d) Order By
3. NULL value is different from a zero value.
Choose one option
a) True
b) False
4. WHERE clause cannot be used with _
Choose one option
a) Select
b) Delete
c) Drop
d) Update
5. Which operator in the where clause signifies “Not Equal”?
a) <>
b)
c) <_>
d) <->
6. Which clause is used in SQL to fetch limited number of records from a table?
Choose one option
a) Select
b) Select limit
c) Select top
d) Top
7. Mysql supports which of the following clause to select a limited number of rows from a table?
a) Select
b) Select top
c) Top
d) Limit
8. What is missing in
ALTER TABLE Employees ADD CHECK (Age >= 18);
Choose one option
a) ALTER TABLE
b) ADD CHECK
c) (Age >= 18)
d) All Correct
9. In SQL, what does the logical operator AND do when used in a WHERE clause?
Choose one option
a) Selects a record if either condition is true
b) Selects a record if both conditions are true
c) Negates a condition
d) None of the above
10. In SQL, how does the compound operator ‘+=’ function?
Choose one option
a) Adds two values
b) Adds a value to a column’s existing value
c) Subtracts one value from another
d) Concatenates strings
11. The NOT NULL constraint enforces a) column to not accept NULL values.
Choose one option
a) True
b) False
12. Correct the syntax error in
UPDATE Products SET Price = Price * 1.1 WHERE Price < 100 OR Price > 200;
Choose one option
a) * 1.1
b) WHERE
c) OR
d) No syntax error
13. Identify the error
SELECT Name FROM Employees WHERE NOT (Age < 30 AND Department = 'Sales');
Choose one option
a) NOT operator
b) < 30
c) AND
d) No error
14. Identify the mistake in
SELECT * FROM Employees WHERE Department = 'HR' XOR Department = 'Finance';
Choose one option
a) XOR operator
b) = ‘HR’
c) = ‘Finance’
d) No mistake, the statement is correct
15. What needs to be changed in
UPDATE Employees SET Salary *= 2 WHERE YearsOfExperience > 5;
Choose one option
a) *= 2
b) WHERE
c) YearsOfExperience > 5
d) All Correct
16. In an SQL query, what role does HAVING play without a GROUP BY clause?
Choose one option
a) It functions as a WHERE clause
b) It has no effect
c) It causes an error
d) It filters aggregated results
17. What happens if you use a column in the SELECT statement that is not in the GROUP BY clause?
Choose one option
a) The query fails
b) The query succeeds, and the column shows arbitrary values
c) The query is automatically corrected
d) The column is ignored
18. Identify the error in
SELECT Department, COUNT(*) FROM Employees GROUP BY Salary;
Choose one option
a) SELECT Department
b) COUNT(*)
c) GROUP BY Salary
d) No error
19. What needs to be corrected in
SELECT AVG(Salary) AS AverageSalary FROM Employees HAVING AverageSalary > 50000;
Choose one option
a) SELECT AVG(Salary)
b) AS AverageSalary
c) FROM Employees
d) HAVING AverageSalary > 50000
20. Correct the syntax error in
SELECT Name, Department, COUNT(*) FROM Employees WHERE Department = 'Sales' GROUP BY Department;
Choose one option
a) SELECT Name
b) Department
c) COUNT(*)
d) WHERE Department = ‘Sales’
21. Identify the error
SELECT Department, SUM(Salary) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;
Choose one option
a) SELECT Department
b) SUM(Salary)
c) GROUP BY Department
d) No Error
22. What is incorrect in
SELECT * FROM Employees ORDER BY 3;
Choose one option
a) SELECT *
b) FROM Employees
c) ORDER BY 3
d) All Correct
23. Identify the mistake in
SELECT Department, MAX(Salary) FROM Employees WHERE MAX(Salary) > 50000 GROUP BY Department;
Choose one option
a) SELECT Department
b) MAX(Salary)
c) HERE MAX(Salary) > 50000
d) GROUP BY Department
24. What needs correction?
SELECT Department, COUNT(EmployeeID) FROM Employees GROUP BY Department HAVING COUNT(EmployeeID) > ALL (SELECT COUNT(EmployeeID) FROM Employees GROUP BY Department);
Choose one option
a) ALL operator
b) COUNT(EmployeeID)
c) No error
d) subquery
25. What is wrong in
SELECT Department, COUNT(*) AS TotalEmployees FROM Employees GROUP BY Department HAVING TotalEmployees > 5 ORDER BY TotalEmployees;
Choose one option
a) SELECT Department
b) COUNT(*) AS TotalEmployees
c) HAVING clause misuse
d) ORDER BY TotalEmployees
====================================================================
Additional MCQ for SQL