Re: select minof two columns
Posted in 1999
Hi there :>
"Sackwitz, Antje" wrote:
>
> Hi,
> I'm a newbie with Informix (coming from Oracle world).
> Now I have the following situation:
> Table tab has col1,col2,col3.
> I want something like: select col1, least(col2,col3) from tab;
> It is possible to do it under Oracle,
> how can I do it with Informix?
> Any information is appreciated,
>
> Antje Sackwitz
I know of no direct way to accomplish this (anyone?)
but I would do it using a stored procedure like
this (assuming the values are INT):
--
CREATE PROCEDURE minval(a INTEGER, b INTEGER) RETURNING INTEGER;IF a>b THEN
RETURN b;
ELSE
RETURN a;
END IF
END PROCEDURE;
and then selecting with something like:
select minval(field1,field2) from sometable
--
Regards,
Dirk
--
-- Dirk Gunsthoevel phone: +49 (0)251 624947
-- Hoeftestr.49 fax: +49 (0)251 624177
-- 48167 Muenster mobile: +49 (0)170 5464715
-- Germany http://members.aol.com/Plabit