Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to include an IF() statement in SQL?

Re: How to include an IF() statement in SQL?

From: Bob Cunningham <bcunn_at_oanet.com>
Date: 1998/09/02
Message-ID: <35eca229.78651855@news.oanet.com>#1/1

On Tue, 01 Sep 1998 17:30:40 -0700, Troy Perchotte <max_at_headroom.com> wrote:

>How do I include a condition within a select statement?
>Something like the following (only one that works):
>
>select if(customers.custid=customers.parentid,'',customers.name) as
>parent_name from customers;
>
>Troy Perchotte
>
>

You can use the DECODE function. E.g.:

SELECT DECODE(custid,parentid,NULL,name) parent_name FROM customers;

Bob Cunningham
bcunn_at_oanet.com Received on Wed Sep 02 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US