Kodewick
Empieza a aprender →
Mini reto←→0 / 70

¿Ya la pesaron?

#058Mini retoCASE + IS NULL5 min

El veterinario pone una etiqueta a cada mascota: 'not weighed' si weight está vacío, 'big' de 15 en adelante y 'small' para el resto. De pets, elige el name y esa etiqueta.

Las tablas
owners
  • idPK
  • name
  • city
  • phone
pets
  • idPK
  • name
  • kind
  • age
  • weight
  • owner_idFK

pets.owner_id → owners.id

owners
idnamecityphone
1LenaOslo555-0101
2MarcoRomeNULL
3PriyaOslo555-0103
4OmarCairoNULL
5SofiaRome555-0105
5 filas
pets
idnamekindageweightowner_id
1Biscuitdog3121
2Mochicat541
3Pepperdog8202
4Nemofish1NULL3
5Lunacat233
6Rexdog1130NULL
7Kiwibird4NULL5
8Tofucat75NULL
8 filas
query.sql
SELECT name,
  CASE
    -- tu código aquí: primero WHEN weight IS NULL, luego WHEN weight >= 15 y luego ELSE 'small'
  END
FROM pets;
Ctrl + Enter también ejecuta
Resultado

Ejecutar muestra lo que da tu consulta. Cuando se vea bien, Enviar.