Bird
0
0

Given a table Sales with column Amount, what will this query return?

medium📝 query result Q4 of 15
SQL - CASE Expressions
Given a table Sales with column Amount, what will this query return?
SELECT Amount, CASE WHEN Amount > 100 THEN 'High' ELSE 'Low' END AS Category FROM Sales;
AOnly rows where Amount is greater than 100
BSum of all Amount values labeled as 'High' or 'Low'
CA list of amounts with 'High' or 'Low' labels based on value
DAn error because CASE cannot be used in SELECT
Step-by-Step Solution
Solution:
  1. Step 1: Understand the CASE expression in SELECT

    The CASE checks each Amount; if greater than 100, it returns 'High', else 'Low'.
  2. Step 2: Analyze query output

    The query returns all rows with Amount and a new column Category showing 'High' or 'Low'.
  3. Final Answer:

    A list of amounts with 'High' or 'Low' labels based on value -> Option C
  4. Quick Check:

    CASE in SELECT = conditional labels [OK]
Quick Trick: CASE can label rows without filtering them [OK]
Common Mistakes:
  • Thinking CASE filters rows
  • Assuming CASE sums values
  • Believing CASE causes errors in SELECT

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes