我有两个 SQLite 表:
锻炼:
WorkoutID WorkoutDate
1 25.01.2012
2 19.04.2012
锻炼练习:
ExerciseID WorkoutID Muscles Exercise Set1_Rep Set1_W Set2_Rep Set2_W
1 1 Abdominals Crunches 20 72,00 22 72,00
2 1 Abdominals Decline Crunch 25 72,00 25 72,00
3 1 Chest Decline Push-Up 12 50,00 10 55,00
4 1 Chest Chain Press 10 55,00 10 60,00
5 1 Chest Machine Bench Press 14 45,00 12 50,00
6 2 Biceps Drag Curl 18 35,00 16 40,00
7 2 Biceps Hammer Curls 10 60,00 10 65,00
8 2 Biceps Preacher Curl 12 35,00 12 40,00
9 2 Biceps Spider Curl 11 50,00 10 50,00
10 2 Neck Chin To Chest Stretch 20 72,00 20 72,00
我想为每个WorkoutDate
and显示Muscles
练习总数、代表总数和总重量,如下所示:
25.01.2012
Abdominals: 2 exercises
92 reps, 288 lbs
Chest: 3 exercises
68 reps, 315 lbs
19.04.2012
Biceps: 4 exercises
99 reps, 375 lbs
Neck: 1 exercise
40 reps, 144 lbs
我得到了每个肌肉群的次数和重量的总和:
SELECT Muscles,
SUM(Set1_Rep)+SUM(Set2_Rep)+SUM(Set3_Rep)+SUM(Set4_Rep)+SUM(Set5_Rep) AS [Reps], SUM(Set1_W)+SUM(Set2_W)+SUM(Set3_W)+SUM(Set4_W)+SUM(Set5_W) AS [Weight]
FROM WorkoutExercises
GROUP BY Muscles
如何计算每天 (WorkoutDate) 每个肌肉群 (Muscles) 的锻炼次数 (Exercise)?