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

Home -> Community -> Usenet -> c.d.o.server -> Re: Creation of a column based on values of other columns, help please!

Re: Creation of a column based on values of other columns, help please!

From: Tim Hall <tim.hall_at_spam.begone>
Date: Fri, 24 Apr 1998 13:02:49 GMT
Message-ID: <35408ca3.17658291@69.0.9.9>


On Fri, 24 Apr 1998 09:57:31 GMT, mark_tortolano_at_dial.pipex.com (Mark Tortolano) wrote:

>Hi, I want to create a View based on a table in Oracle. I've got two
>columns in the table with numeric values that indicate user
>preferences. I want to create a third column in this view that will
>have a true/false value that will be "true" if either of the other
>columns has a non-zero number in it.
>
>Is it possible to do this in SQL alone, perhaps using DECODE? Or would
>I have to use PL/SQL to create the view. If so, how?
>

DECODE(NVL(col1,0),0,decode(NVL(col2,0),0,FALSE,TRUE),TRUE) should do it.

DECODE(NVL(col1,0)*NVL(col2,0),0,FALSE,TRUE) will work as well.

Of course, if the two columns are not null, you won't need the NVLs

Tim Hall, Indus International (was TSW International) tim.hall (at) iint.com
http://www.indusworld.com

Replace domain name with the iint.com before replying via email! Received on Fri Apr 24 1998 - 08:02:49 CDT

Original text of this message

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