Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: oracle cross table
A copy of this was sent to analyst_user_at_my-deja.com
(if that email address didn't require changing)
On Mon, 10 Jan 2000 14:53:08 GMT, you wrote:
>I have the following data.
>
>Name Age Contact Amount
>--------------------------------------------------------
>John Smith 30 Jane Doe 10
>John Smith 30 Joe Klein 10
>
>
>I am trying to get this result.
>
>Name Age Primary Contact Secondary Contact Amount
>---------------------------------------------------------------------
>John Smith 30 Jane Doe Joe Klein 10
>
how did you know 'jane doe' was the primary vs joe klein the secondary? If you had a column "Contact Type", the query:
select name, age, amount,
max( decode( contact_type, 'PRIMARY', contact, null ) ) primary_contact, max( decode( contact_type, 'SECONDARY', contact, null ) ) secondary_contactfrom T
would work....
>
>I tried something like this:
>Select name,age,
> decode(contact,'Jane Doe','Jane Doe',NULL) Primary,
> decode(contact,'Joe Klein','Joe Klein',NULL) Secondary,
> amount,
>From Table
>Group by name,age,decode(contact,'Jane Doe','Jane Doe',NULL)
> decode(contact,'Joe Klein','Joe Klein',NULL)
> amount;
>
>
>Any help would be really appreciated.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Jan 10 2000 - 10:07:32 CST