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!

Q241

Q241 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

Q242

Q242 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

Q243

Q243 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

Q244

Q244 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

Q245

Q245 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

Q246

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

A

Replace 'INNER JOIN' with 'LEFT JOIN'

B

Change 'ON' to 'USING'

C

Remove 'Employees.' prefix from 'DepartmentID'

D

No error

Q247

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

A

Change 'LEFT JOIN' to 'RIGHT JOIN'

B

Replace 'USING (DepartmentID)' with 'ON Employees.DepartmentID = Departments.DepartmentID'

C

Add 'AS EmployeeName, AS DepartmentName' for clarity

D

No error

Q248

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

A

Change 'RIGHT OUTER JOIN' to 'LEFT OUTER JOIN'

B

Replace 'WHERE' with 'AND'

C

Remove 'Orders.' prefix from 'OrderDate'

D

No error

Q249

Q249 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)

Q250

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

A

Replace 'FULL JOIN' with 'FULL OUTER JOIN'

B

Change 'ON' to 'USING'

C

Add 'WHERE Orders.OrderDate IS NOT NULL'

D

No error

Q251

Q251 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

Q252

Q252 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

Q253

Q253 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

Q254

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

A

Change 'CROSS JOIN' to 'INNER JOIN'

B

Add 'ON' clause with condition

C

Remove 'FROM Employees'

D

No error

Q255

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

A

Replace 'FULL OUTER JOIN' with 'LEFT JOIN'

B

Change 'WHERE' to 'AND'

C

Remove 'WHERE Departments.DepartmentName IS NULL'

D

No error

Q256

Q256 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

Q257

Q257 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

Q258

Q258 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

Q259

Q259 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

Q260

Q260 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

Q261

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

A

Change 'ROUND' to 'ROUNDDOWN'

B

Replace '2' with '-2'

C

Add 'AS RoundedSalary' for clarity

D

No error

Q262

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

A

Change 'SQRT' to 'SQUARE'

B

Replace 'Age >= 0' with 'Age > 0'

C

Add 'AS SquareRootAge' for clarity

D

No error

Q263

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

A

Change 'CEILING' to 'FLOOR'

B

Replace 'AS RoundedPrice' with 'AS PriceCeiling'

C

Remove 'WHERE Price > 0'

D

No error

Q264

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

A

Replace 'PI()' with '3.14'

B

Change 'Radius * Radius' to 'Power(Radius, 2)'

C

Remove 'AS Area'

D

No error

Q265

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

A

Change 'SQUARE' to 'SQRT'

B

Replace 'Length' with 'Width'

C

Add 'AS SquareLength' for clarity

D

No error

Q266

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

A

Change 'INT' to 'INTEGER'

B

Replace 'CAST' with 'CONVERT'

C

Add 'AS IntegerSalary' for clarity

D

No error

Q267

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

A

Change 'VARCHAR' to 'DATE'

B

Replace '103' with '101'

C

Remove 'WHERE StartDate IS NOT NULL'

D

No error

Q268

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

A

Change 'TRY_CONVERT' to 'CONVERT'

B

Replace 'INT' with 'INTEGER'

C

Remove 'WHERE Age IS NOT NULL'

D

No error

Q269

Q269 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

Q270

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

A

Change 'COALESCE' to 'NVL'

B

Replace '0' with '10000'

C

Add 'AS DefaultSalary' for clarity

D

No error

ad vertical
ad