Kodewick
Start learning →
Basic←→0 / 70

All the dogs together

#029BasicAggregates3 min

The vet is sending a van to pick up all the dogs and needs to know their total weight. From the pets table, add up the weight of the pets whose kind is 'dog'; the result is a single number.

The tables
owners
idnamecityphone
1LenaOslo555-0101
2MarcoRomeNULL
3PriyaOslo555-0103
4OmarCairoNULL
5SofiaRome555-0105
5 rows
pets
idnamekindageweightowner_id
1Biscuitdog3121
2Mochicat541
3Pepperdog8202
4Nemofish1NULL3
5Lunacat233
6Rexdog1130NULL
7Kiwibird4NULL5
8Tofucat75NULL
8 rows
query.sql
-- your code here: WHERE to keep the dogs, then SUM(weight)
SELECT weight
FROM pets;
Ctrl + Enter runs too
Result

Run shows what your query gives. When it looks right, Submit.