sql banner

SQL Multiple Choice Questions (MCQs) and Answers

Master SQL with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of SQL. Begin your placement preparation journey now!

Q61

Q61 Correct the syntax error in
"UPDATE Products SET Price = Price * 1.1 WHERE Price < 100 OR Price > 200;"

A

* 1.1

B

WHERE

C

OR

D

No syntax error

Q62

Q62 What is incorrect in
"SELECT EmployeeID, Salary FROM Employees WHERE Salary BETWEEN 30000 AND 50000;"?

A

SELECT

B

EmployeeID, Salary

C

BETWEEN

D

All Correct

Q63

Q63 In "SELECT Name FROM Employees WHERE NOT (Age < 30 AND Department = 'Sales');",
identify the error.

A

NOT operator

B

< 30

C

AND

D

No error

Q64

Q64 Identify the mistake in
"SELECT * FROM Employees WHERE Department = 'HR' XOR Department = 'Finance';"

A

XOR operator

B

= 'HR'

C

= 'Finance'

D

No mistake, the statement is correct

Q65

Q65 What needs to be changed in
"UPDATE Employees SET Salary *= 2 WHERE YearsOfExperience > 5;"?

A

*= 2

B

WHERE

C

YearsOfExperience > 5

D

All Correct

Q66

Q66 What does the WHERE clause do in an SQL query?

A

Sorts the result set

B

Filters rows before grouping

C

Joins tables

D

Filters rows after grouping

Q67

Q67 What is the purpose of the ORDER BY clause in SQL?

A

Filters rows

B

Sorts the result set

C

Groups rows

D

Joins tables

Q68

Q68 In SQL, how does the GROUP BY clause function when combined with an aggregate function like SUM or COUNT?

A

It calculates the aggregate for the entire table

B

It groups rows based on unique values in a column and calculates the aggregate for each group

C

It filters the rows before aggregation

D

It sorts the result set

Q69

Q69 What is the main difference between WHERE and HAVING clauses in SQL?

A

WHERE filters rows before grouping, HAVING filters rows after grouping

B

HAVING filters rows before grouping, WHERE filters rows after grouping

C

No difference

D

WHERE is used with aggregate functions, HAVING is not

Q70

Q70 In an SQL query, what role does HAVING play without a GROUP BY clause?

A

It functions as a WHERE clause

B

It has no effect

C

It causes an error

D

It filters aggregated results

Q71

Q71 How does the ORDER BY clause treat NULL values by default?

A

It places them at the beginning of the result set

B

It places them at the end of the result set

C

It ignores them

D

It causes an error

Q72

Q72 What happens if you use a column in the SELECT statement that is not in the GROUP BY clause?

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

Q73

Q73 Can the ORDER BY clause use column aliases defined in the SELECT statement?

A

Yes

B

No

C

Only if they are numerical

D

Only in subqueries

Q74

Q74 What is the effect of combining GROUP BY with ORDER BY in an SQL query?

A

GROUP BY overrides ORDER BY

B

ORDER BY overrides GROUP BY

C

They can be used together for organized grouping and sorting

D

They cannot be used together in the same query

Q75

Q75 In SQL, can the HAVING clause be used without an aggregate function?

A

Yes, it acts like a WHERE clause

B

No, it must be used with an aggregate function

C

Yes, but it has no effect

D

No, it causes an error

Q76

Q76 What is incorrect in
"SELECT Name FROM Employees WHERE Department = 'Sales' ORDER BY Age;"?

A

SELECT Name

B

WHERE Department = 'Sales'

C

ORDER BY Age

D

All Correct

Q77

Q77 Identify the error in
"SELECT Department, COUNT(*) FROM Employees GROUP BY Salary;"

A

SELECT Department

B

COUNT(*)

C

GROUP BY Salary

D

No error

Q78

Q78 What needs to be corrected in
"SELECT AVG(Salary) AS AverageSalary FROM Employees HAVING AverageSalary > 50000;"?

A

SELECT AVG(Salary)

B

AS AverageSalary

C

FROM Employees

D

HAVING AverageSalary > 50000

Q79

Q79 Correct the syntax error in
"SELECT Name, Department, COUNT(*) FROM Employees WHERE Department = 'Sales' GROUP BY Department;"

A

SELECT Name

B

Department

C

COUNT(*)

D

WHERE Department = 'Sales'

Q80

Q80 In "SELECT Department, SUM(Salary) FROM Employees GROUP BY Department HAVING COUNT(*) > 5;",
identify the error.

A

SELECT Department

B

SUM(Salary)

C

GROUP BY Department

D

No Error

Q81

Q81 What is incorrect in
"SELECT * FROM Employees ORDER BY 3;"?

A

SELECT *

B

FROM Employees

C

ORDER BY 3

D

All Correct

Q82

Q82 Identify the mistake in
"SELECT Department, MAX(Salary) FROM Employees WHERE MAX(Salary) > 50000 GROUP BY Department;"

A

SELECT Department

B

MAX(Salary)

C

WHERE MAX(Salary) > 50000

D

GROUP BY Department

Q83

Q83 In "SELECT Department, COUNT(EmployeeID) FROM Employees GROUP BY Department HAVING COUNT(EmployeeID) > ALL (SELECT COUNT(EmployeeID) FROM Employees GROUP BY Department);"
what needs correction?

A

The ALL operator

B

COUNT(EmployeeID)

C

No error

D

The subquery

Q84

Q84 Correct the error in
"SELECT Name FROM Employees WHERE Department IN (SELECT Department FROM Departments WHERE Location = 'New York') ORDER BY Name GROUP BY Department;"

A

WHERE Department IN

B

ORDER BY Name

C

GROUP BY Department

D

No error

Q85

Q85 What is wrong in
"SELECT Department, COUNT(*) AS TotalEmployees FROM Employees GROUP BY Department HAVING TotalEmployees > 5 ORDER BY TotalEmployees;"?

A

SELECT Department

B

COUNT(*) AS TotalEmployees

C

HAVING clause misuse

D

ORDER BY TotalEmployees

Q86

Q86 What is the main difference between UNION and UNION ALL in SQL?

A

UNION removes duplicates, UNION ALL does not

B

UNION ALL removes duplicates, UNION does not

C

No difference

D

UNION is faster than UNION ALL

Q87

Q87 What needs to be corrected in
"SELECT Name FROM Employees UNION ALL SELECT Name FROM Managers;"?

A

All Correct

B

The UNION ALL keyword

C

The SELECT statement

D

The table names

Q88

Q88 Identify the error in
"SELECT Name, Department FROM Employees UNION SELECT Name FROM Managers;"

A

The UNION keyword

B

The number of columns in SELECT statements

C

The table names

D

No error

Q89

Q89 What does an INNER JOIN do in SQL?

A

Joins rows that satisfy a condition in either table

B

Joins all rows from both tables

C

Joins rows with matching values in both tables

D

Joins rows that do not match in either table

Q90

Q90 What is the main characteristic of a FULL OUTER JOIN?

A

It combines all records from both tables when there are no matches

B

It only joins rows with matching values in both tables

C

It excludes all unmatched rows

D

It joins rows that satisfy a condition in either table

ad vertical
ad