These expressions are syntactically correct, but do not correspond to the explanation.
Sometimes, it helps to reverse a logical condition.
According to the explanation, there is an error if stnd_sht
is nicht gegeben
and if both the mass_sof
and mass_6m
values are NULL.
This would correspond to the following expression:
SELECT baum_id,
CASE WHEN stnd_sht = 'nicht gegeben' AND
mass_sof IS NULL AND
mass_6m IS NULL
THEN 'fehler'
ELSE 'plausibel'
END AS plaus
FROM baeume;
This could be simplified a little:
SELECT baum_id,
CASE WHEN stnd_sht = 'nicht gegeben' AND
COALESCE(mass_sof, mass_6m) IS NULL
THEN 'fehler'
ELSE 'plausibel'
END AS plaus
FROM baeume;