Re: display table row into column

From: Shakespeare <whatsin_at_xs4all.nl>
Date: Tue, 03 Mar 2009 09:10:52 +0100
Message-ID: <49ace610$0$191$e4fe514c_at_news.xs4all.nl>



srinivasarao22_at_gmail.com schreef:
> On Feb 26, 5:48 pm, shweta.kapar..._at_googlemail.com wrote:

>> Hi All
>>
>> I have :
>>
>> SQL> create table t1( col1 varchar2(10), col2 varchar2(10),col3
>> varchar2(10));
>>
>> Table created.
>>
>> SQL>
>>
>> SQL> insert into t1(col1,col2,col3) values ('A','B','C');
>>
>> 1 row created.
>>
>> SQL> insert into t1(col1,col2,col3) values ('D','E','F');
>>
>> 1 row created.
>>
>> SQL> insert into t1(col1,col2,col3) values ('G','H','I');
>>
>> 1 row created.
>>
>> SQL> commit;
>>
>> Commit complete.
>>
>> SQL> select * from t1;
>>
>> COL1 COL2 COL3
>> ---------- ---------- ----------
>> A B C
>> D E F
>> G H I
>>
>> i want to write select query which should give me the output:
>> as
>>
>> col1 col2 col3
>> ---- ------ ------
>> B E H
>>
>> Regards
>>
>> Shweta
> 
> 
> 
>  SELECT  (SELECT col2 FROM t1 WHERE col1='A') col1,(SELECT col2 FROM
> t1 WHERE col1='D') col2,(SELECT col2 FROM t1 WHERE col1='G') col3 FROM
> t1
> WHERE  ROWNUM<2
> 

Duh.... why not:
select 'B' col1, 'E' col2, 'H' col3 from dual? If you want to hard-code your queries, be consequent!

Shakespeare Received on Tue Mar 03 2009 - 02:10:52 CST

Original text of this message