Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sql select question

Re: sql select question

From: R T <rthumsi_at_hotmail.com>
Date: 4 Mar 2003 16:49:16 -0800
Message-ID: <94f01c2b.0303041649.58703ae7@posting.google.com>


If the 'name's are literals you can do the following:

select a, max(decode(n,'name1', v)) name1_val, 
          max(decode(n,'name2', v)) name2_val,
          max(decode(n,'name3', v)) name3_val,....
from yourtbl
group by a;

anthony.robins_at_micromuse.com (ayrobins) wrote in message news:<616b69af.0302191056.3ae384e7_at_posting.google.com>...
> thanx.
> this brings me closer.
>
>
>
> Billy Verreynne <vslabs_at_onwe.co.za> wrote in message news:<b2vat8$rrh$1_at_ctb-nnrp2.saix.net>...
> > ayrobins wrote:
> >
> > > All i want is to transform the name of a name/value table into a specific
> > > column.
> > > specifically i have a table called conn_address
> > >
> > > name value
> > > --------- ----------------
> > > host xxx
> > > port 123
> > >
> > > so i want to do a select on conn address where the result would be.
> > > xxx 123
> > > on the same row.
> >
> > Try something like this:
> >
> > SQL> create table tst ( a number, b varchar2(20), c varchar(20) );
> >
> > Table created.
> >
> > SQL> insert into tst values( 1, 'name1', 'value1' );
> >
> > 1 row created.
> >
> > SQL> insert into tst values( 1, 'name2', 'value2' );
> >
> > 1 row created.
> >
> > SQL> insert into tst values( 2, 'name3', 'value3' );
> >
> > 1 row created.
> >
> > SQL> insert into tst values( 2, 'name4', 'value4' );
> >
> > 1 row created.
> >
> > SQL> insert into tst values( 3, 'name5', 'value5' );
> >
> > 1 row created.
> >
> > SQL> SELECT
> > 2 t1.c, t2.c
> > 3 FROM tst t1, tst t2
> > 4 WHERE t1.a = t2.a
> > 5 AND t1.b < t2.b;
> >
> > C C
> > -------------------- --------------------
> > value1 value2
> > value3 value4
Received on Tue Mar 04 2003 - 18:49:16 CST

Original text of this message

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