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

Home -> Community -> Usenet -> c.d.o.tools -> Re: SELECT question

Re: SELECT question

From: OraSaurus <granaman_at_no.spam>
Date: 1997/09/13
Message-ID: <341ada4c.0@iorich.phonet.com>#1/1

In article <340D9D3B.5E46FC51_at_mail1.dh.trw.com>,

   Rollin Weeks <Rollin.Weeks_at_mail1.dh.trw.com> wrote:
>Fred Hurtubise wrote:
>
>>
>> Question is :
>>
>> is there a way to select only the column that aren't null
>> something like select * from table where column is not null???
>
>What you describe sounds trivial; you have already stated it:
>
>select col1, col2, . . . from <table_name>
>where colx is not null (and coly is not null and colz is not null);
>
>Regards
>Rollin Weeks

It is not as trivial as suggested here. The original question was how to select only the non-null columns. This example would discard all rows where any of the columns were null! The simple answer is no - you can't do it. The real answer is that you could use decode and || to select only the non-null columns in SQL*Plus or use PL/SQL to manipulate the data prior to output. An example of the SQL*Plus approach might look something like the following...

Assume: The table "JUNK" contains varchar2 columns A, B, and C.

         The delimiting character in your output is to be "|"

SQL> select decode(A,null,null,A || "|")

            || decode(B,null,null,B || "|")
            || C from JUNK;

.. or some such thing.

---
Spam-Proofing in effect: Please change "no.spam" to "phonet.com" for e-mail.
Received on Sat Sep 13 1997 - 00:00:00 CDT

Original text of this message

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