Kodewick
Start learning →
Mini challenge←→0 / 70

Weighed yet?

#058Mini challengeCASENULL5 min

The vet gives every pet a tag: 'not weighed' if weight is empty, 'big' for 15 and up, 'small' for the rest. From pets, pick the name and that tag.

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
SELECT name,
  CASE
    -- your code here: first WHEN weight IS NULL, then WHEN weight >= 15, then ELSE 'small'
  END
FROM pets;
Ctrl + Enter runs too
Result

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