The column currenttotalvalue has a numeric type with a length of 14 and 2 digits for percision. The initial SELECT didn't used the CAST, but the result was also wrong.
I'm (still) using the postgres version 8.2.
Thanks for your support.
I'm just curious why do you use UPPER() function in the ORDER BY clause?