Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP60- SELECT DISTINCT
Message
From
24/08/1999 11:08:39
 
 
To
24/08/1999 09:31:52
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00257019
Message ID:
00257075
Views:
24
>SELECT DISTINCT * FROM ACCOUNTS gives me the non dup records from my accounts table. How do I get the dups using the same command? Is there something like SELECT NOT DISTINCT * FROM ACCOUNTS?
>

You can do this in two stages:

SELECT Primary Key, CNT(*) AS NumOccurs FROM ACCOUNTS ;
GROUP BY Primary Key ;
HAVING NumOccurs > 1 ;
INTO CURSOR temp
* Temp now contains the Primary keys of all dups
SELECT * FROM ACCOUNTS ;
WHERE Primary Key IN (SELECT Primary Key FROM temp) ;
ORDER BY Primary Key
* The results are all duplicated records

If Primary Key is an expression, you'll probably want to name it with an AS clause in the first SELECT, and then reference that name in the subquery in the second SELECT.

>Any suggestions or comments will be welcome, thank you.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform