Re: IF-like function in Oracle?
From: Mike Philippens <mikephil_at_metropolis.nl>
Date: 1995/09/28
Message-ID: <DFLqwI.CK3_at_news.metropolis.nl>#1/1
Date: 1995/09/28
Message-ID: <DFLqwI.CK3_at_news.metropolis.nl>#1/1
chuckh_at_ix.netcom.com (Chuck Hamilton) wrote:
>IF X > Y
> THEN return value A as the column's value
> ELSE return value B as the column's value
>I can use DECODE() if I just want to test for simple coditions like =
>or <>, but I don't know how to make it handle >, <, >=, <=. Do I have
>to write my own custom functions to do this?
You could of course use PL/SQL, but if you insist on DECODE, here is a way of doing it:
DECODE(SIGN(x-y), 0,value_if_x_equals_y ,-1,value_if_x_smaller_y , 1,value_if_x_greater_y)
+------------------------------------------------------------+ | Mike Philippens - Gorinchem - The Netherlands, Europe | | Vijfhart Automatisering bv | | Oracle Specialists in Training and Consultancy | | Utrecht The Netherlands | +------------------------------------------------------------+Received on Thu Sep 28 1995 - 00:00:00 CET