Question : DECODE in Sybase

Is there any sql command in isql that can perform function just like decode in ORACLE (i.e. if-then-else)?

Answer : DECODE in Sybase

Yes, as of ASE 11.5, you can use the CASE statement:

select CASE
  when (col1 = 1) then "yes"
  when (col1 = 2) then "no"
  else "maybe"
end as "MyAnswer"
from mytable

Prior to 11.5, there were sometimes solutions using something called "point characteristic functions" (described in the book "Optimizing Transact SQL"  (http://www.sqlforum.com)  ) or other tricks, but these
are certainly harder to use and read.

-bret


Random Solutions  
 
programming4us programming4us