Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Combine records
Ning li wrote:
> Hi,
>
> I am running a join query which returns several records with the same id
> (c_id). The query and the selected records are as the following:
>
> select c_id, product, country, region
> from mytable1
>
> Results: c_id product country region
> 1 toy1 Turkey
> Middle East
> 1 toy1 Turkey
> Europe
> ..................
>
> As you can see, a country can belong to multiple regions. If the
> records have the same values for all the columns except the region, like the
> above,
> I would like to combine the records into one record, as the following:
> c_id product country region
> 1 toy1 Turkey Middle East -
> Europe
>
> Is there a simple way to do it or is PL/SQL needed for the job?
>
> I don't have control over the table design BTW.
>
> Thanks in advance.
>
> Nick
>
>
>
GROUP BY Clause.
You can find examples at http://tahiti.oracle.com and demos at: http://www.psoug.org/reference/group_by.html
-- Daniel Morgan http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp damorgan_at_x.washington.edu (replace 'x' with a 'u' to reply)Received on Thu Dec 11 2003 - 02:28:04 CST