Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Counting duplicates in SQL
DA Morgan wrote on 02.09.2006 18:47:
>>> So for example for "Sausage" I would like to report how many rows
>>> have an ID
>>> of 82785, 83780 and 99999 respectively. I can't see how I can adapt
>>> my statement above. Is there another approach using just SQL?
>>
>> SELECT product_id, count(*)
>> FROM
>> (
>> your statement goes here
>> )
>> WHERE product_name = 'Sausage'
>> GROUP BY product_id
>>
>> Thomas
>
> to which I would add HAVING COUNT(*) > 1
I thought that at first as well, but the OP said "to report how many rows have an ID" which sounds more like he'd like to have the ones with only one row as well.
Thomas Received on Sat Sep 02 2006 - 12:25:05 CDT
![]() |
![]() |