Bird
0
0

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

medium📝 query result Q13 of 15
SQL - CASE Expressions
Given the table Employees with column Salary, what will this query return?
SELECT Salary, CASE WHEN Salary > 5000 THEN 'High' ELSE 'Low' END AS SalaryLevel FROM Employees;
AOnly salaries below 5000 with label 'Low'
BOnly salaries above 5000 with label 'High'
CA list of salaries with labels 'High' for salaries above 5000 and 'Low' otherwise
DAn error because CASE cannot be used in SELECT
Step-by-Step Solution
Solution:
  1. Step 1: Understand the CASE logic in SELECT

    The CASE checks each Salary; if greater than 5000, label 'High', else 'Low'.
  2. Step 2: Check what rows are returned

    The query returns all rows with Salary and corresponding label, no rows are filtered out.
  3. Final Answer:

    A list of salaries with labels 'High' for salaries above 5000 and 'Low' otherwise -> Option C
  4. Quick Check:

    CASE labels salaries conditionally [OK]
Quick Trick: CASE in SELECT labels rows, does not filter [OK]
Common Mistakes:
  • Thinking CASE filters rows like WHERE
  • Assuming only 'High' salaries show
  • Believing CASE causes syntax error in SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes