Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to flatten cols into rows
Mark.Powell_at_eds.com (Mark D Powell) wrote in message news:<2687bb95.0401300620.5a379b89_at_posting.google.com>...
> peteg_at_garlic.com (hedrew3) wrote in message news:<aad10be0.0401292322.7b6c320b_at_posting.google.com>...
> > I have a single table, as follows:
> >
> > Col_A Col_B
> > ------ ------
> > Joe X
> > Joe Y
> > Joe Z
> > Bob A
> > Bob B
> >
> > and I need to have a result set that looks like:
> >
> > Joe X Y Z
> > Bob A B
> >
> > The first column may have anywhere from 1 to max of 5 entries.
> > Is this possible in SQL, or do I need to do it in PL/SQL?
> >
> > TIA
> >
> > Pete
>
>
> Pete, yes this can be done in SQL. There is in fact more than one
> available method for transforming the row data into column data, but
> which methods are available to you depends on your version of Oracle.
>
> This looks like a school assignment so I am going to recommend you
> search the newsgroup archives and look up PIVOT tables. There have
> been several posts with examples on this topic over the last few
> years.
>
> You can search the archives via groups.google.com
>
> HTH -- Mark D Powell --
Mark,
<grin> This most certainly is not a school assignment. I'm over 50, and haven't been inside a classroom in a looooong time. Anyway, your hint to look at pivot tables is exactly what I was looking for. A lot of times when people search on the forums it's the exact term (e.g. pivot) is all that is needed to send them on the right track. Thank you,
Pete Received on Fri Jan 30 2004 - 13:21:08 CST
![]() |
![]() |