Re: Something like DECODE( ) in Oracle...
Posted in 2000
Informix supports the decode as well as case statement within a query.
I know that these two are in 9.2 (Informix.2000). I think that they are
also in 7.31.
The decode syntax looks somthing like:
select name, DECODE(evaluation,
"poor", 0,
"fair", 1,
"good", 2,
"fantastic",3) as grade....
Additionally, we have a case statement which would look like:
select name, CASE score
when <= 60 then "Failed"
when (>60 and <= 70) then "Poor"
when (>70 and <= 80) then "Fair"
when (> 80 and <= 90) then "Good"
when (>90) then "Excellent"
END.....
nextream wrote:
> Hi.
> Is there any function similar to decode() in Oracle?
>
> I am trying to get query result as follows:
> acct D C
> A01 100 0
> A02 0 200
>
> from the table as follows:
> acct crdr amount
> A01 D 100
> A02 C 200
>
> My first thought is:
> select acct, amount, 0 from table1 where crdr="D"
> union
> select acct, 0, amount from table1 where crdr="C"> too tricky or heavy load?
>
> In Oracle, this will be done with only 2 decode() I think...
> but I have to make it go with Informix, and,
> I'm trying not to make user defined stored procedure (if possible).
>
> Thanks for any comments~