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: SQL*PLUS select statment

Re: SQL*PLUS select statment

From: DA Morgan <damorgan_at_psoug.org>
Date: Wed, 30 May 2007 13:09:52 -0700
Message-ID: <1180555791.252619@bubbleator.drizzle.com>


sunadmn wrote:
> On May 30, 11:35 am, DA Morgan <damor..._at_psoug.org> wrote:

>> sunadmn wrote:
>>> Afternoon all I have a simple query that I am running to get a dataset
>>> for BIRT. The query runs fine but I need to manipulate the data into a
>>> single column; Here is an example:
>>> SQL> select
>>> ONLINEFX.EVERYDAY_SUMMARY.COUNT,ONLINEFX.EVERYDAY_SUMMARY.GOOD_COUNT,ONLINEFX.EVERYDAY_
>>> SUMMARY.FAIR_COUNT,ONLINEFX.EVERYDAY_SUMMARY.UNACCEPTABLE_COUNT
>>>   2  from ONLINEFX.EVERYDAY_SUMMARY
>>>   3  where ONLINEFX.EVERYDAY_SUMMARY.PERIOD = to_char(sysdate-1, 'YYYY-
>>> MM-DD');
>>>      COUNT    GOOD_COUNT FAIR_COUNT UNACCEPTABLE_COUNT
>>>      ----------     ----------              ----------
>>> ------------------
>>>       6577       6146                 91                 340
>>> I want to have the data returned in the format of multiple rows and a
>>> single column like this:
>>> COUNT                               6577
>>> GOOD_COUNT                   6146
>>> FAIR_COUNT                      91
>>> UNACCEPTABLE_COUNT   340
>>> I know this has to be possible, but I lack the SQL skill to get to
>>> where I need to be if anyone could give me some pointers or point me
>>> to a good ref doc that would be great.
>>> Cheers,
>>> -Steve
>> Morgan's Library atwww.psoug.org
>> Look up DECODE.
>> --
>> Daniel A. Morgan
>> University of Washington
>> damor..._at_x.washington.edu
>> (replace x with u to respond)
>> Puget Sound Oracle Users Groupwww.psoug.org

>
> Daniel,
>
> I think my last message was lost somehow, I apologize if this is a
> double post. From what I gather on DECODE its an if/than/else
> substitution method which is not the result I am looking for. Let me
> try to explain this a bit better. I have a simple select statement
> that returns data in the form of:
>
> column column column column
> data data data data
>
> This is good but inorder to read the "data" back into my reporting
> tool I need it to look like this:
>
> data
> data
> data
> data
>
> Now as long as we keep the original horizontal ordering (left -> right
> = up -> down) I have no need for the column names anymore. Am I way
> off base here with what I am trying to get? Did I overlook something
> in the DECODE docs?
>
> Thanks,
> -Steve

Maxim's demo is what I wanted you to discover with DECODE. It can be done with CASE too.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Wed May 30 2007 - 15:09:52 CDT

Original text of this message

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