>>>>Hi, Is is possible to use an sql statement(s) to count and number duplicates? The original table looks something like this, showing an excerpt where there are three entries for one date:
>>>
>>>
>>>SELECT *
>>> FROM ch5
>>> WHERE mdate IN (
>>> SELECT mdate FROM ch5 ;
>>> GROUP BY mdate ;
>>> HAVING COUNT(mdate) > 1)
>>>
>>>
>>>>
>>>>Mdate Vs
>>>>05/28/2013 v1
>>>>05/28/2013 v1
>>>>05/28/2013 v1
>>>>
>>>>
>>>>The following is a start in that it will give me a table that shows how many duplicates exist for each date.
>>>>
>>>>
>>>>SELECT mdate,COUNT(mdate) FROM ch5 ;
>>>> INTO TABLE dups;
>>>> GROUP BY mdate ;
>>>> HAVING COUNT(mdate) > 1
>>>>
>>>>
>>>>Here is a part of the report that the above produces:
>>>>
>>>>
>>>>mdate cnt_mdate
>>>>05/28/2013 3
>>>>08/28/2013 2
>>>>
>>>>
>>>>And by using set relationship and a do while loop, I can count and label the duplicates. But I was just wondering if an SQL statement(s) could do it all? The final output that I need is::
>>>>
>>>>
>>>>Mdate cnt/date Vs
>>>>05/28/2013 1 v1
>>>>05/28/2013 2
>>>>05/28/2013 3
>>>>
>>>>
>>>>Thanks,
>>>>Steve
>>
>>Thank you, I tried your code:
>>
>>
>>SELECT * ;
>> FROM ch5 ;
>> WHERE mdate IN ( ;
>> SELECT mdate FROM ch5 ;
>> GROUP BY mdate ;
>> HAVING COUNT(mdate) > 1)
>>
>>
>>but I get an error: file ch5.dbf does not exist
>
>Why would it? ch5 is a table isn't it? You used it in your example. Sorry, but this is the way to do it. You must have done something else wrong.
>
>Walter,
You are Correct. I had made a mistake. You code now gives a print out of all duplicates (with counts > 1); but it does not number the members of each group of duplicates, or otherwise mark off the appearance of the first of each of the duplicates?
Thank you,
Steve