Refresher on Aggregates
Question:
You will need to know aggregate functions before attempting the other questions.
We would like to find the total weight of cats grouped by age. But only return those groups with a total weight larger than 12.
Return: age, sum(weight) Order by: age Show Table Schema
Cats:
name | varchar |
breed | varchar |
weight | float |
color | varchar |
age | int |

Correct output but can you use 'group by'?
×
Good work!
Group by and Having are required by aggregate functions like sum(). Aggregate functions are used for finding sums and averages. next question
Desired output:
age | total_weight |
2 | 19.6 |
4 | 15.8 |
5 | 15.4 |
select age, sum(weight) as total_weight from cats group by age having sum(weight) > 12 order by age