Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: sql select question
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.
Reid Lai <reidlai_at_reidlai.com> wrote in message news:<3E4E36AE.80804_at_reidlai.com>...
> If you are talking to build up matrix dynamically, there is no way in
> SQL only. You must find other client tools to do so, like Privot Table
> in Excel, etc.
>
> ayrobins wrote:
>
> > Hi guys,
> >
> > this should be easy but i cannot figure out how to do this.
> > The purpose of this is to create a view out of a name/value table and
> > make each name a column.
> >
> > create table tst
> > (
> > a integer,
> > n varchar(10),
> > v varchar(10)
> > );
> >
> > insert into tst values(1, 'name1a', 'value1a');
> > insert into tst values(1, 'name1b', 'value1b');
> > insert into tst values(2, 'name2a', 'value2a');
> > insert into tst values(2, 'name2b', 'value2b');
> >
> > select a, v from tst where a in (1);
> >
> > which gives me:
> > A V
> > ---------- ----------
> > 1 value1a
> > 1 value1b
> >
> > What i want is to put the values associated with the same 'a' on 1 row.
> > So i want to see 1 row consisting of '1, value1a, value1b'.
> >
> > thanx in advance
> > anthony
> >
Received on Tue Feb 18 2003 - 11:55:43 CST