1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Functions in Snowflake

Connected

Exercise

Which workouts burn the most calories?

It's almost the New Year, one of the busiest times for gyms everywhere. To help motivate members, the marketing team would like to create personalized content for each member to push them towards their most effective workout type. They need you to build a pivoted table using Snowflake to show the average calories burned for each member and gym, by workout type. Good luck!

Instructions

100 XP
  • Create a CTE called gym_workouts that returns the user_id, gym_id, workout_type, calories_burned from the visits table and location for 'Premium' gym_type in the gyms table.
  • Exclude the gym_id field from the final result set.
  • Pivot the records in the gym_workouts temporary result set; find the sum of calories burned for each workout type in workout_type.
Powered by Snowflake