"Camilo Sperberg" <unreal4u@xxxxxxxxxxxxxxxxx> 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 -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general