db2 => select case s1 when 0 then 'Active' when 1 then 'InActive' end
"STATUS" f
rom statustable
STATUS
--------
InActive
InActive
InActive
Active
Active
Active
Active
InActive
8 record(s) selected.
db2 => select case s1 when 0 then 'Active' when 1 then 'InActive' end
"STATUS" f
rom statustable
STATUS
--------
InActive
InActive
InActive
Active
Active
Active
Active
InActive
8 record(s) selected.
whitsey - 24 May 2007 07:59 GMT
> db2 => select case s1 when 0 then 'Active' when 1 then 'InActive' end
> "STATUS" f
[quoted text clipped - 12 lines]
>
> 8 record(s) selected.
Thanks swami
Hi whitsey,
if you have a table, that relates the numbers to strings, use this table to
join. If not, you could use a common table expression "result" and join it
like this:
with result( num, str ) as
(
values (1, "Active"),
(2, "Inactive"),
(3, "Trial"),
(4, "Demo")
)
select result.str
from users, result
where users.status = result.num
Not tested, might need minor adjustments, but you get the idea?
HTH,
Joachim Banzhaf
> How can I modify return values?
>
[quoted text clipped - 30 lines]
>
> Is there a way to do this within the SQL statement???