Re: display table row into column

From: Michael Austin <maustin_at_firstdbasource.com>
Date: Tue, 03 Mar 2009 15:59:04 -0600
Message-ID: <JMhrl.14859$as4.14654_at_nlpi069.nbdc.sbc.com>



srinivasarao22_at_gmail.com wrote:
> 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
> 

Srini - say WHAT??? you might as well have hard-code the results too...

I see nothing in his data that suggests there is relationship between the 3 rows he is suggesting.. fix the database design before trying to solve a problem that shouldn't exist. Received on Tue Mar 03 2009 - 15:59:04 CST

Original text of this message