Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How do I transpose a table?
Lee,
Check out Tom Kyte's response to this:
http://asktom.oracle.com/pls/ask/f?p=4950:8:825293::NO::F4950_P8_DISPLAYID,F
4950_P8_CRITERIA:766825833740,%7Bpivot%7D%20and%20%7Btable%7D
and
http://asktom.oracle.com/pls/ask/f?p=4950:8:825293::NO::F4950_P8_DISPLAYID,F
4950_P8_CRITERIA:124812348063,%7Bpivot%7D%20and%20%7Btable%7D
hope this helps.
chris.
-- Christopher Beck, Principal Technologist, Oracle Corporation christopher.beck_at_oracle.com Beginning Oracle Programming, http://www.amazon.com/exec/obidos/ASIN/186100690X "Lee Farrant" <leefarrant_at_hotmail.com> wrote in message news:97ad5817.0205151035.74ab91be_at_posting.google.com...Received on Wed May 15 2002 - 15:53:46 CDT
> I think the word for this is transpose but I am not sure.
>
> I have a table which is in the following format
>
> Customer 1 Subscriber 1
> Customer 1 Subscriber 2
> Customer 1 Subscriber 3
> Customer 1 Subscriber 4
> Customer 2 Subscriber 5
> Customer 2 Subscriber 6
> Customer 3 Subscriber 7
> Customer 3 Subscriber 8
>
> I need to transform this table into the following format so there is
> only one record for each customer and the subscriber fields 1-x are
> going across the table.
>
> Customer 1 Subscriber 1 Subscriber 2 Subscriber 3 Subscriber 4
> Customer 2 Subscriber 5 Subscriber 6
> Customer 3 Subscriber 7 Subscriber 8
>
> Its unusual that a customer will more than 4 subscriptions but
> basically I will not no which customer has the most subscriptions
> until a process the table in some way, I assume I would need this
> information to decide how many subscription columns to create on the
> new table. am i making sense?
>
> Is there any code SQL out there that will already do this that I could
> edit as I am very stuck.
>
> thanks
>
> Lee leefarrant_at_hotmail.com