Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP60- Dabatases and Tables
Message
From
27/12/1999 23:16:01
 
 
To
27/12/1999 21:47:37
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00308802
Message ID:
00309050
Views:
39
Ok, either I misunderstood what you were trying to do, or you misunderstood the purpose of the example I gave you. The COUNT(*), and the HAVING clause fill the result cursor with only records that have duplicates. A duplicate, by definition is a record that shares a set of values with at least one other record. The COUNT() field tells you how many records share the attributes, and the having clause eliminates records with no duplicates.

The trick is, the result set doesn't show EACH duplicate record, but a grouped aggregate of all of the records fitting the description. If you want to actually select all records that are duplicates, you have to use the results of the first query and join them to the second using the GROUP BY criteria in the join:

SELECT COUNT(*), * FROM MyTable GROUP BY Field1, Field2 INTO CURSOR Dupes

SELECT MyTable.* ;
FROM MyTable, Dupes ;
WHERE MyTable.Field1 = Dupes.Field1 ;
AND MyTable.Field2 = Dupes.Field2 ;
INTO CURSOR AllDupes

The second result set will contain a copy of EVERY record that has a duplicate. Not ONE of the duplicates, but all of them, which means if you are trying to eliminate dupes, one of these records is a good one, and one is the throwaway.


>QUESTION #1:
>I have been playing with the SELECT command you showed me and I don't understand why the COUNT(*) and the HAVING clause are needed in it. I get the same results (unique records) if I do the following two commands:
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform