Re: display table row into column
From: <srinivasarao22_at_gmail.com>
Date: Mon, 2 Mar 2009 23:09:31 -0800 (PST)
Message-ID: <2f621a72-af0f-49ac-bde3-d38c7b579c2a_at_l33g2000pri.googlegroups.com>
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
Date: Mon, 2 Mar 2009 23:09:31 -0800 (PST)
Message-ID: <2f621a72-af0f-49ac-bde3-d38c7b579c2a_at_l33g2000pri.googlegroups.com>
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
Received on Tue Mar 03 2009 - 01:09:31 CST