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!

Q91

Q91 What is a LEFT JOIN in SQL?

A

A join that retrieves records from the left table only

B

A join that retrieves records from the right table only

C

A join that retrieves all records from the left table and matched records from the right table

D

A join that retrieves matched records from both tables

Q92

Q92 In SQL, what does a SELF JOIN refer to?

A

Joining a table with a different table

B

Joining a table with itself using a different alias

C

Joining a table with a copy of itself

D

Joining a table with its foreign key

Q93

Q93 What is an EQUI JOIN?

A

A join using an equality operator

B

A join using any comparison operator other than equality

C

A join based on the equidistant principle

D

A join that always produces an equal number of rows from both tables

Q94

Q94 In a RIGHT JOIN, what happens to the rows from the right table that have no matches in the left table?

A

They are included in the result set with NULLs in the columns of the left table

B

They are excluded from the result set

C

They are included as duplicates

D

They are replaced with values from the left table

Q95

Q95 How does a NON-EQUI JOIN differ from an EQUI JOIN?

A

NON-EQUI JOIN uses non-equality operators, EQUI JOIN uses equality operators

B

NON-EQUI JOIN is faster than EQUI JOIN

C

NON-EQUI JOIN cannot be used with WHERE clause, EQUI JOIN can

D

There is no difference

Q96

Q96 What needs to be corrected in
"SELECT * FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;"?

A

All Correct

B

INNER JOIN

C

ON clause

D

Table names

Q97

Q97 Identify the error in
"SELECT Employees.Name, Departments.Name FROM Employees LEFT JOIN Departments USING (DepartmentID);"

A

The LEFT JOIN

B

USING (DepartmentID)

C

No error

D

The SELECT statement

Q98

Q98 Correct the syntax error in
"SELECT * FROM Orders RIGHT OUTER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Orders.OrderDate = '2023-01-01';"

A

RIGHT OUTER JOIN

B

ON clause

C

WHERE clause

D

No syntax error

Q99

Q99 What is incorrect in
"SELECT A.Name, B.Name FROM Employees A, Employees B WHERE A.EmployeeID < B.EmployeeID;"?

A

The SELECT statement

B

The WHERE clause

C

No error, it is a SELF JOIN

D

The table aliases (A, B)

Q100

Q100 In "SELECT * FROM Orders FULL JOIN Customers ON Orders.CustomerID = Customers.ID;",
identify the error.

A

The FULL JOIN keyword

B

ON clause

C

No error

D

The table names

Q101

Q101 What needs to be changed in
"SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID <> Customers.ID;"?

A

INNER JOIN

B

<> operator

C

No change

D

The ON clause

Q102

Q102 Correct the syntax error in
"SELECT * FROM Employees A LEFT JOIN Departments B ON A.DepartmentID == B.DepartmentID;"

A

LEFT JOIN

B

ON clause

C

No syntax error

D

== operator

Q103

Q103 Identify the issue in
"SELECT E.Name, D.Name FROM Employees E JOIN Departments D ON E.DepartmentID > D.DepartmentID;"

A

JOIN keyword

B

> operator

C

No error

D

The ON clause

Q104

Q104 In "SELECT * FROM Employees CROSS JOIN Departments;",
what needs correction?

A

CROSS JOIN

B

No error

C

The SELECT statement

D

The table names

Q105

Q105 What is wrong in
"SELECT * FROM Employees FULL OUTER JOIN
Departments ON Employees.
DepartmentID = Departments.DepartmentID WHERE Departments.
DepartmentName IS NULL;"?

A

FULL OUTER JOIN

B

ON clause

C

WHERE clause

D

All Correct

Q106

Q106 What is the purpose of the ROUND function in SQL?

A

To round a number to the nearest integer

B

To round a number to a specified number of decimal places

C

To find the square root of a number

D

To return the value of PI

Q107

Q107 What does the CEILING function do in SQL?

A

Returns the smallest integer greater than or equal to a given number

B

Returns the largest integer less than or equal to a given number

C

Calculates the square of a number

D

Calculates the square root of a number

Q108

Q108 In SQL, what is the result of the SQRT function when applied to a negative number?

A

A positive number

B

Zero

C

An error

D

A negative number

Q109

Q109 What is the purpose of the PI function in SQL?

A

To return the value of PI

B

To calculate the perimeter of a circle

C

To calculate the area of a circle

D

To return the radius of a circle

Q110

Q110 How does the SQUARE function differ from the POWER function in SQL?

A

SQUARE calculates the square, POWER calculates any exponent

B

SQUARE and POWER are the same

C

SQUARE calculates the square root, POWER calculates the square

D

SQUARE calculates any exponent, POWER calculates the square

Q111

Q111 What needs to be corrected in
"SELECT ROUND(Salary, 2) FROM Employees;"?

A

All Correct

B

ROUND

C

Salary

D

2

Q112

Q112 Identify the error in
"SELECT Name, SQRT(Age) FROM Employees WHERE Age >= 0;"

A

SELECT Name

B

SQRT

C

Age >= 0

D

No error

Q113

Q113 Correct the syntax error in
"SELECT CEILING(Price) AS RoundedPrice FROM Products WHERE Price > 0;"

A

CEILING

B

RoundedPrice

C

FROM Products

D

No syntax error

Q114

Q114 What is incorrect in
"SELECT Name, PI() * Radius * Radius AS Area FROM Circles;"?

A

PI()

B

Radius * Radius

C

AS Area

D

All Correct

Q115

Q115 In "SELECT SQUARE(Length) FROM Rectangles;",
what needs correction?

A

SQUARE

B

Length

C

No error

D

FROM Rectangles

Q116

Q116 What needs to be corrected in
"SELECT CAST(Salary AS INT) FROM Employees;"?

A

All Correct

B

CAST

C

Salary

D

AS INT

Q117

Q117 Identify the error in
"SELECT CONVERT(VARCHAR, StartDate, 103) FROM Projects WHERE StartDate IS NOT NULL;"

A

CONVERT function

B

VARCHAR keyword

C

StartDate column

D

No Error

Q118

Q118 Correct the syntax error in
"SELECT Name, TRY_CONVERT(INT, Age) AS IntegerAge FROM Employees WHERE Age IS NOT NULL;"

A

TRY_CONVERT function

B

INT keyword

C

Age column

D

No Error

Q119

Q119 What does the COALESCE function do in SQL?

A

Returns the first non-null value in a list

B

Combines multiple rows into a single string

C

Duplicates a string

D

Compares two expressions and returns NULL if they are equal

Q120

Q120 What needs to be corrected in
"SELECT COALESCE(Salary, 0) FROM Employees;"?

A

All Correct

B

COALESCE

C

Salary

D

0

ad vertical
ad