>>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...