Conditional logic & CASE
Exercise · SQL & Querying

Predict, then run it

Predict the output

reads(sensor, moisture) = (s1,NULL),(s2,1). Label dry/ok/missing so the NULL sensor reads 'missing' — searched CASE, IS NULL first:

SELECT sensor, CASE WHEN moisture IS NULL THEN 'missing' WHEN moisture = 1 THEN 'ok' ELSE 'other' END AS label FROM reads ORDER BY sensor;

Predict the exact output.