QuizzesCASE Expressions — Concept Check
intermediate
sql

CASE Expressions — Concept Check

Questions on CASE Expressions. CASE is SQL's conditional expression; simple CASE compares one value to multiple options, while searched CASE evaluates independent boolean conditions for flexible branching.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on CASE Expressions — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.An SQL query uses a CASE expression to categorize orders based on their status. What will be the output label for a status code 'shipped'?

    • AOn the Way
    • BDelivered
    • CProcessing
    • DAwaiting Payment
  2. 2.A database query uses a searched CASE to assign salary bands. What salary band is assigned to an employee earning 85,000?

    • AMid-level
    • BPrincipal
    • CSenior
    • DJunior
  3. 3.When using a simple CASE expression, what happens if none of the WHEN conditions match and no ELSE is specified?

    • ACauses an error
    • BExecutes the first WHEN condition
    • CReturns a default value
    • DReturns NULL
  4. 4.A query sorts orders by custom status priority using CASE in ORDER BY. What priority is given to 'paid' status?

    • A2
    • B3
    • C4
    • D1
  5. 5.Which scenario is best suited for a searched CASE expression?

    • AMapping a status code to a label
    • BChecking if a value falls within a range
    • CComparing a value to a single constant
    • DChecking for NULL values
  6. 6.A query uses CASE in a GROUP BY clause to bucket order sizes. If total_amount is 1500, which bucket does it fall into?

    • Amedium
    • Bunknown
    • Clarge
    • Dsmall
  7. 7.Why might mixing data types in different THEN branches of a CASE expression cause an error?

    • ACASE requires ELSE to determine type
    • BCASE cannot handle NULL values
    • CThe return type is set by the first THEN branch
    • DSQL can only handle one data type
  8. 8.A query uses CASE for conditional aggregation. What happens if a category is not matched in any CASE condition?

    • AAn error is thrown
    • BThe sum is NULL
    • CThe sum for that category is 0
    • DThe sum includes all unmatched categories