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: Impossible SQL Task ??

Re: Impossible SQL Task ??

From: Sean McMurray <smcmurr_at_xmission.com>
Date: Fri, 30 Apr 1999 12:08:20 -0700
Message-ID: <3729FFA3.2F0043E0@xmission.com>


Matt Randle wrote:

> We have a list of IDs / Codes / Identifiers as follows,
>
> ID Code Identifier
>
> 1 A Matthew
> 1 B Randle
> 2 A Larry
> 2 B Ellison
> 3 A Dave
> 4 B Some Surname
>
> We need to re-orient the table so it comes back as,
>
> ID A B
>
> 1 Matthew Randle
> 2 Larry Ellison
> 3 Dave
> 4 Some Surname
>
> Is this possible in SQL ?? I can obviously do it programatically but it
> would be more elegent to do it with on SQL statement ?? I seem to remember
> reading about some 'projection' facility availiable some SQL server that
> does this sort of thing.

Assuming that there are only two codes per id,

select a.id, a.identifier, b.identifier

    from table_name a, table_name b
    where a.id=b.id and

        a.code='A' and b.code='B' Received on Fri Apr 30 1999 - 14:08:20 CDT

Original text of this message

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