Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Help with Group By clause
SELECT C.CustomerID, C.Name, C.Address, COUNT(V.VisitID)
FROM CustomerTable C, VisitsTable V
WHERE C.CustomerID=V.CustomerID(+)
group by c.customerID, c.name, c.address;
"Randy Harris" <randy.harris_at_nospam.net> wrote in message
news:OTUaa.5905$se1.3188022_at_newssvr28.news.prodigy.com...
> I believe this can be done, but I am SQL challenged and would appreciate
> help.
>
> I need to return several fields and the count of related records in
another
> table. It is simplified here:
>
> CustomerTable
> CustomerID
> Name
> Address
>
> VisitsTable
> CustomerID
> VisitID
>
> This, of course, doesn't work, I think it needs a GROUP BY clause:
>
> SELECT C.CustomerID, C.Name, C.Address, COUNT(V.VisitID)
> FROM CustomerTable C, VisitsTable V
> WHERE C.CustomerID=V.CustomerID(+);
>
> Thanks in advance for your help,
> --
> Randy Harris
>
>
>
Received on Tue Mar 11 2003 - 13:13:27 CST