"Camilo Sperberg" <unreal4u@chilehardware.com> writes:
> SELECT
> CASE mid WHEN NULL THEN CAST(0 AS integer)
> ELSE mid
> END AS mid,
BTW, the reason this doesn't work is the same reason "mid = NULL"
doesn't work, because that's exactly what the CASE condition is
treated as. The COALESCE trick is certainly the best solution
for this specific need, but the more general way would be
CASE WHEN mid IS NULL THEN ... ELSE ...
regards, tom lane