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

Exercise

BMI bucket by sport

You are looking to understand how BMI differs by each summer sport. To answer this, set up a report that contains the following:

  • sport, which is the name of the summer sport
  • bmi_bucket, which splits up BMI into three groups: <.25, .25-.30, >.30
  • athletes, or the unique number of athletes

Definition: BMI = 100 * weight / (height squared).

Also note that CASE statements run row-by-row, so the second conditional is only applied if the first conditional is false. This makes it that you do not need an AND statement excluding already-mentioned conditionals.

Feel free to reference the E:R Diagram.

Instructions

100 XP
  • Build a query that pulls from summer_games and athletes to show sport, bmi_bucket, and athletes.
  • Without using AND or ELSE, set up a CASE statement that splits bmi_bucket into three groups: '<.25', '.25-.30', and '>.30'.
  • Group by the non-aggregated fields.
  • Order the report by sport and then athletes in descending order.