RE: SQL help
Date: Tue, 24 May 2016 01:31:32 -0400
Message-ID: <BLU181-W66AD2817AD72437807686FD84F0_at_phx.gbl>
Hi Steve,
This works great with 2 rows. Thank you so much.
If the number of records increase to more than 2, if there is a way to extend this query? In my scenario, I wouldn't know how many rows would be returned from this query, hence I am looking for something dynamic..
Thanks
Upendra
From: stbaldwin_at_multiservice.com
To: oracle-l_at_freelists.org; nupendra_at_hotmail.com
Subject: Re: SQL help
Date: Tue, 24 May 2016 04:39:52 +0000
Maybe a cartesian join to a 2-row dual. Something like (untested):
with t2 as (select rownum rnum from dual connect by level <= 2) select case rnum when 1 then a else b end from test, t2;
hth,
Steve
From: oracle-l-bounce_at_freelists.org <oracle-l-bounce_at_freelists.org> on behalf of Upendra nerilla <nupendra_at_hotmail.com>
Sent: Tuesday, 24 May 2016 7:58:50 AM
To: Oracle-L
Subject: SQL help
Hey guys,
Could someone help with a SQL:
I have a test table with 2 rows:
create table test (a varchar2(50), b varchar2(50)); insert into test values ('one', 'first row'); insert into test values ('two', 'second row'); commit;
I need a query that shows the output as the following (without using union). Order of the values is not important.
OUTPUT
one
first row
two
second row
I thought unpivot might work, poked around a bit.. my brain is too tired to think..
Thanks in advance
-Upendra ------------------------------------------------------- This email is intended solely for the use of the addressee and may contain information that is confidential, proprietary, or both. If you receive this email in error please immediately notify the sender and delete the email. -------------------------------------------------------
-- http://www.freelists.org/webpage/oracle-lReceived on Tue May 24 2016 - 07:31:32 CEST