Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detect double records
Message
From
14/12/2007 14:05:02
 
 
To
14/12/2007 07:37:59
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01275807
Message ID:
01275951
Views:
6
>>how is the easier way to detect double records?
>>
>>I have a table like this:
>>
>>StockID
>>-------
>>01001
>>01002
>>01003
>>01001 => double
>>01004
>>01002 => double
>>
>>how can I detect those double records without a complicated code?
>>
>>thanks for the help.
>
>
>SELECT stockID FROM yourtable GROUP BY stockID HAVING COUNT(*) > 1
Tore,

There is a slight difference if you use COUNT(*) or COUNT(stockID) -- the former gives you groupings including NULL values, the latter does not.

I have always used a slightly version of this statement:
SELECT stockID, COUNT(stockID) AS DupeCounter  FROM yourtable GROUP BY stockID HAVING DupeCounter > 1
The nice thing about this version is that it will show you the number of records for each duplicated item, should you care...
Pertti Karjalainen
Product Manager
Northern Lights Software
Fairfax, CA USA
www.northernlightssoftware.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform