Last Updated On
Welcome to the SQL Quiz!
SQL Multiple Choice Questions – MCQ3
Answers
1) d) We can insert and delete rows in a view
2) d) Order By
Order By clause is used to sort the retrieved data in ascending or descending order. Group By clause is used to group the result-set by one or more columns. Order and Group are not valid SQL commands.
3) a) True
NULL signifies an unknown value or a value which doesn’t exist during the creation of the record.
4) c) Drop
5) a) <>
6) c) Select top
7) d) Limit
All database systems does not supports SELECT TOP clause. It can be used in SQL. Mysql supports the LIMIT clause to fetch a limited number of records from the database table.
8) d) All correct
9) b) Selects a record if both conditions are true
10) b) Adds a value to a column’s existing value
11) a) True
12) d) No syntax error
13) d) No error
14) a) XOR operator
SQL does not have an XOR logical operator. Use AND/OR instead.
15) d) All Correct
The compound operator ‘*=’ is correctly used to double the salary of specified employees.
16) a) It functions as a WHERE clause
Without GROUP BY, HAVING functions like a WHERE clause, filtering rows based on specified conditions.
17) a) The query fails
Using a column in SELECT that is not part of GROUP BY without an aggregate function causes the query to fail.
18) c) GROUP BY Salary
GROUP BY should be used with the column mentioned in SELECT, here it should be GROUP BY Department.
19) d) HAVING AverageSalary > 50000
HAVING should be used with an aggregate function directly, not with an alias.
20) a) SELECT Name
Name should be included in the GROUP BY clause or used within an aggregate function.
21) d) No Error
The query correctly groups by Department and uses HAVING to filter groups.
22) d) All Correct
ORDER BY 3 is correct, indicating ordering by the third column in the SELECT list.
23) c) WHERE MAX(Salary) > 50000
Aggregate functions such as MAX should be used in the HAVING clause when filtering groups created by the GROUP BY clause.
24) c) No error
The query correctly uses HAVING with ALL to compare counts across departments.
25) c) HAVING clause misuse
The original statement had an error in the HAVING clause. It incorrectly used the alias ‘TotalEmployees’. The correct HAVING clause should be “HAVING COUNT(*) > 5”.