Inline select

On Jul 6,  6:37, Stephen Ranson wrote:

> Does anyone know of a way to implement an in-line or immediate if in a
> select?  What i mean is to do something like
>
> select a.col1,
>           if(a.col2 < some value then 'Y', else 'N')
>
> from table a;

Presumably a.col2 is a numeric value of some sort?  If so, you MAY be
able to trick something out like this:

	CHAREXTRACT('NY',(a.col2/someValue+2)/(a.col2/someValue+1))

which works if a.col2 is a nonnegative integer.  (using the fact that
in nonnegative integers, (x+2)/(x+1) is 2 iff x = 0, else 1).
If the value can be negative you may be able to think of a more complicated
transformation that works.  If the values are floats, int'ing the
quotient may work.

-- 
Karl Schendel            Phone: (412) 963-8844
Telesis Computer Corp      Fax: (412) 963-1373
wiz@telesis.com
Ingres Q & A
To William's Home Page

© William Yuan 2000

Email William