1. Learn
  2. /
  3. Courses
  4. /
  5. Reporting in SQL

Exercise

CASE statement refresher

CASE statements are useful for grouping values into different buckets based on conditions you specify. Any row that fails to satisfy any condition will fall to the ELSE statement (or show as null if no ELSE statement exists).

In this exercise, your goal is to create the segment field that buckets an athlete into one of three segments:

  • Tall Female, which represents a female that is at least 175 centimeters tall.
  • Tall Male, which represents a male that is at least 190 centimeters tall.
  • Other

Each segment will need to reference the fields height and gender from the athletes table. Leverage CASE statements and conditional logic (such as AND/OR) to build this.

Remember that each line of a case statement looks like this: CASE WHEN {condition} THEN {output}

Instructions

100 XP
  • Update the CASE statement to output three values: Tall Female, Tall Male, and Other.