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!

Q121

Q121 Identify the error in
"SELECT Name, NULLIF(Age, 30) FROM Employees WHERE Age IS NOT NULL;"

A

NULLIF

B

Age

C

30

D

No error

Q122

Q122 Correct the syntax error in
"SELECT NVL(Salary, 'Not Provided') FROM Contractors;"

A

NVL

B

Salary

C

'Not Provided'

D

No syntax error

Q123

Q123 What is incorrect in
"SELECT COALESCE(FirstName, LastName, 'Unknown') FROM Authors;"?

A

COALESCE

B

FirstName

C

LastName

D

All Correct

Q124

Q124 In "SELECT Name, NVL2(Salary, Salary * 1.1, Salary) AS NewSalary FROM Employees;",
what needs correction?

A

NVL2

B

Salary * 1.1

C

Salary

D

No error

Q125

Q125 What is the main use of the CASE statement in SQL?

A

To execute a sequence of commands

B

To handle errors

C

To perform if-then-else type logic

D

To loop through records

Q126

Q126 What needs to be corrected in
"SELECT Name, CASE WHEN Age >= 18 THEN 'Adult' ELSE 'Minor' END FROM Employees;"?

A

All Correct

B

CASE WHEN

C

THEN 'Adult'

D

ELSE 'Minor'

Q127

Q127 Identify the error in
"SELECT Name, CASE Gender WHEN 'M' THEN 'Male' WHEN 'F' THEN 'Female' END AS Gender FROM Employees;"

A

CASE Gender

B

WHEN 'M' THEN 'Male'

C

WHEN 'F' THEN 'Female'

D

No error

Q128

Q128 What needs to be corrected in
"SELECT CURRENT_DATE FROM Employees;"?

A

All Correct

B

CURRENT_DATE

C

FROM Employees

D

The entire query

Q129

Q129 Identify the error in
"SELECT Name, DATEDIFF(year, HireDate, GETDATE()) AS YearsWorked FROM Employees;"

A

DATEDIFF

B

year

C

HireDate

D

No error

Q130

Q130 Correct the syntax error in
"SELECT Name, DATEADD(MONTH, 6, HireDate) FROM Employees;"

A

DATEADD

B

MONTH

C

6

D

No syntax error

Q131

Q131 What is incorrect in
"SELECT EXTRACT(MONTH FROM OrderDate) AS OrderMonth FROM Orders;"?

A

EXTRACT

B

MONTH FROM

C

OrderDate

D

All Correct

Q132

Q132 In "SELECT Name, AGE(BirthDate) AS Age FROM Customers;",
what needs correction?

A

AGE

B

BirthDate

C

AS Age

D

No error

Q133

Q133 What needs to be corrected in
"SELECT ABS(-123) FROM Dual;"?

A

All Correct

B

ABS

C

-123

D

FROM Dual

Q134

Q134 Identify the error in
"SELECT Name, CEILING(Salary) FROM Employees WHERE Salary > 0;"

A

CEILING

B

Salary

C

WHERE Salary > 0

D

No error

Q135

Q135 Correct the syntax error in
"SELECT Name, ROUND(Salary, -2) FROM Employees;"

A

ROUND

B

Salary, -2

C

FROM Employees

D

No syntax error

Q136

Q136 What is incorrect in
"SELECT MAX(Salary) - MIN(Salary) AS SalaryRange FROM Employees;"?

A

MAX(Salary)

B

MIN(Salary)

C

AS SalaryRange

D

All Correct

Q137

Q137 In "SELECT Name, LOG(Salary, 10) AS LogSalary FROM Employees WHERE Salary > 0;",
what needs correction?

A

LOG

B

Salary, 10

C

AS LogSalary

D

No error

Q138

Q138 What needs to be corrected in
"SELECT CONCAT(FirstName, ' ', LastName) FROM Employees;"?

A

All Correct

B

CONCAT

C

FirstName

D

LastName

Q139

Q139 Identify the error in
"SELECT SUBSTRING(Name, 1, 3) AS ShortName FROM Products;"

A

SUBSTRING

B

Name, 1, 3

C

AS ShortName

D

No error

Q140

Q140 Correct the syntax error in
"SELECT Name, CHARINDEX('a', Name) FROM Employees WHERE Name IS NOT NULL;"

A

CHARINDEX

B

'a', Name

C

FROM Employees

D

No syntax error

Q141

Q141 What is incorrect in
"SELECT UPPER(Name) FROM Employees;"?

A

UPPER

B

Name

C

FROM Employees

D

All Correct

Q142

Q142 In "SELECT Name, LTRIM(RTRIM(Name)) AS TrimmedName FROM Customers;",
what needs correction?

A

LTRIM

B

RTRIM

C

Name

D

No error

Q143

Q143 What is a correlated subquery in SQL?

A

A subquery that can be executed independently of the outer query

B

A subquery that uses values from the outer query

C

A subquery that returns multiple columns

D

A subquery used in the FROM clause

Q144

Q144 Identify the error in
"SELECT Name FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM Employees);"

A

SELECT Name

B

WHERE Salary

C

(SELECT AVG(Salary) FROM Employees)

D

No error

Q145

Q145 What needs to be corrected in
"SELECT Name FROM Employees WHERE EXISTS (SELECT * FROM Departments WHERE Employees.DepartmentID = Departments.DepartmentID);"?

A

EXISTS clause

B

SELECT *

C

FROM Departments

D

No error

Q146

Q146 Correct the syntax error in
"SELECT Name, (SELECT MAX(Salary) FROM Employees) AS MaxSalary FROM Employees WHERE DepartmentID = (SELECT DepartmentID FROM Departments WHERE Name = 'HR');"

A

(SELECT MAX(Salary) FROM Employees)

B

AS MaxSalary

C

WHERE DepartmentID

D

No syntax error

Q147

Q147 What is a view in SQL?

A

A physical table stored in the database

B

A temporary table created during a session

C

A virtual table based on the result-set of an SQL statement

D

A duplicate copy of another table

Q148

Q148 What is a materialized view in SQL?

A

A view that is automatically updated when the underlying tables change

B

A view that is created for temporary use only

C

A view that is stored physically on the disk

D

A view that can be indexed

Q149

Q149 Identify the error in
"CREATE VIEW ActiveEmployees AS SELECT * FROM Employees WHERE Status = 'Active';"

A

CREATE VIEW

B

ActiveEmployees

C

SELECT * FROM Employees

D

No error

Q150

Q150 What needs to be corrected in
"CREATE OR REPLACE VIEW DepartmentSummary AS SELECT DepartmentID, COUNT(*) FROM Employees GROUP BY DepartmentID;"?

A

CREATE OR REPLACE VIEW

B

DepartmentSummary

C

SELECT DepartmentID, COUNT(*)

D

No error

ad vertical
ad