哪一種運動消耗更多卡路里?
你想先掌握一些關於健身訓練的高層資訊。例如總消耗卡路里與平均消耗卡路里等數值,對想提升訓練效果的健身房會員很有幫助。幸好,你已經有工具可以做到!
本練習屬於課程
Snowflake 的資料型別與函式
練習說明
- 針對每個
workout_type,計算calories_burned的總和。 - 新增一個欄位,儲存每個
workout_type的calories_burned平均值。 - 建立一個欄位,將
calories_burned的平均值四捨五入到小數點後 2 位。 - 以
workout_type彙總紀錄,避免發生錯誤。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
SELECT
workout_type,
-- Find the total number of calories burned
___ AS total_calories_burned,
-- Store the average calories burned
___ AS avg_calories_burned,
-- Round the average calories burned to 2 decimal points
___(___, ___) AS rounded_avg_calories_burned
FROM CORE_GYM.visits
-- Aggregate records by workout_type
___;