pgsql-bugs(at)postgresql(dot)org writes:
> foobar=# select text(CASE WHEN (cashback = NULL or cashback = 0) THEN '0' ELSE cashback END) from transaction_payments where idnum = 139 and payment_type = 6;
> text
> -----------------------
> 1.01855797968803e-312
> (1 row)
Try not quoting the '0'. For reasons that I don't recall at the moment,
7.0 has a problem coercing unknown-type literals to the proper datatype
in CASE expressions. It seems to work OK in 7.1 though.
regards, tom lane