Skip to content

Basic SQL MCQ Revision

Multiple-choice revision for basic SELECT, DISTINCT, ordering, and expressions.

Builds on Basic SQL Commands, ORDER BY and LIMIT and DISTINCT and Aliases

Stage 1intro3 min read

Remember that SELECT name salary FROM employees is commonly parsed as name AS salary; it is ambiguous style, not necessarily a missing-comma syntax error.

1. Select only specific columns

Question

Which query selects only the name and salary columns?

Correct Answer

SELECT name, salary FROM employees;

Explanation

To fetch only specific columns, write the column names after SELECT separated by commas.

  • SELECT chooses columns
  • FROM employees tells SQL which table to read

Why others are wrong

  • SELECT (name, salary) → invalid syntax
  • SELECT name salary → parsed by many databases as name AS salary; valid but unclear style
  • SELECT * name, salary → invalid syntax

2. Purpose of DISTINCT

Question

What is the purpose of DISTINCT in a SELECT statement?

Correct Answer

Removes duplicate rows

Explanation

DISTINCT returns only unique values and removes duplicates from the result.

Example

SELECT DISTINCT city FROM customers;

If multiple customers belong to the same city, each city appears only once.


3. Clause used to filter rows

Question

Which clause is used to filter rows?

Correct Answer

WHERE

Explanation

WHERE filters rows based on a condition.

Example

SELECT * FROM employees
WHERE salary > 50000;

Only rows matching the condition are returned.


4. If no rows satisfy WHERE

Question

What is the output if no rows satisfy the WHERE condition?

Correct Answer

Empty result set

Explanation

If no rows match the condition:

  • SQL does not throw an error
  • SQL does not return NULL
  • SQL returns 0 rows

This is called an empty result set.

Example

SELECT * FROM employees
WHERE salary > 1000000;

If no employee matches, output is simply empty.


5. Comparing with NULL using =

Question

What is the output of:

SELECT name
FROM employees
WHERE bonus = NULL;

Correct Answer

No rows

Explanation

This is one of the most common SQL traps.

At first glance, it looks like this should return employees whose bonus is NULL (Neha and Pooja), but it does not.

In SQL, NULL means unknown or missing value.

So this condition:

bonus = NULL

does not check whether bonus is empty.

It asks:

“Is bonus equal to an unknown value?”

That comparison is never true.

So SQL returns no rows.

Correct way

SELECT name
FROM employees
WHERE bonus IS NULL;

Correct Output

Neha, Pooja

Rule to remember

  • = NULL is wrong
  • != NULL is wrong
  • IS NULL is correct
  • IS NOT NULL is correct

6. Not equal operator (<>)

Question

What is the output of:

SELECT name
FROM employees
WHERE salary <> 60000;

Correct Answer

Amit, Rahul, Pooja

Explanation

<> means not equal to.

So SQL returns employees whose salary is not 60000.

Check

  • Amit → 50000 → yes
  • Neha → 60000 → no
  • Rahul → 45000 → yes
  • Pooja → 70000 → yes
  • Karan → 60000 → no

Output

Amit, Rahul, Pooja


7. Multiple conditions with AND

Question

What is the output of:

SELECT name
FROM employees
WHERE salary * 2 >= 120000 AND age < 35;

Correct Answer

Karan

Explanation

Both conditions must be true:

  1. salary * 2 >= 120000
  2. age < 35

Check

  • Amit → 100000 → no
  • Neha → 120000 yes, but age = 35 → no
  • Rahul → 90000 → no
  • Pooja → 140000 yes, but age = 40 → no
  • Karan → 120000 yes and age = 30 yes

Output

Karan


8. Arithmetic with NULL

Question

What is the output of:

SELECT name
FROM employees
WHERE (salary + bonus) > 65000;

Correct Answer

Karan only

Explanation

If any value in arithmetic is NULL, the result becomes NULL.

salary + NULL = NULL

And:

NULL > 65000

is not true.

So rows with NULL bonus are ignored.

Check

  • Amit → 50000 + 5000 = 55000 → no
  • Neha → 60000 + NULL = NULL → no
  • Rahul → 45000 + 3000 = 48000 → no
  • Pooja → 70000 + NULL = NULL → no
  • Karan → 60000 + 6000 = 66000 → yes

Output

Karan only


Quick Revision Summary

TopicKey Point
Select specific columnsUse column names separated by commas
DISTINCTRemoves duplicate rows
WHEREFilters rows
No match in WHEREReturns empty result set
= NULLAlways returns no rows
IS NULLCorrect way to check NULL
<>Not equal to
ANDBoth conditions must be true
Arithmetic with NULLResult becomes NULL

In this topic

Done with this topic?

How well do you know it?

PreviousString Functions