Bird
0
0

Given the table Employees with column salary, what rows will this query return?

medium📝 query result Q13 of 15
SQL - CASE Expressions
Given the table Employees with column salary, what rows will this query return?
SELECT * FROM Employees WHERE CASE WHEN salary >= 50000 THEN 1 ELSE 0 END = 1;
ARows where salary is less than 50000
BRows where salary is exactly 50000
CAll rows regardless of salary
DRows where salary is 50000 or more
Step-by-Step Solution
Solution:
  1. Step 1: Understand the CASE condition

    The CASE returns 1 if salary is 50000 or more, else 0.
  2. Step 2: Apply the WHERE filter

    The WHERE clause keeps rows where CASE result equals 1, so salary must be at least 50000.
  3. Final Answer:

    Rows where salary is 50000 or more -> Option D
  4. Quick Check:

    salary >= 50000 = filtered rows [OK]
Quick Trick: CASE returns 1 for salary ≥ 50000, filter keeps those rows [OK]
Common Mistakes:
  • Thinking it returns rows below 50000
  • Confusing equality with greater than
  • Ignoring ELSE result

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes