I am trying to get multiple columns and show duplicate ItemCodes form a table. Ie. if an ItemCode is repeated more than once.
Using the query:
SELECT ItemCode
,DuplicateCount = COUNT(*)
FROM IQR1
WHERE WhsCode = 01
GROUP BY
ItemCode
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
I get 38 records with duplicate counts of 2 each.
When I try to get another column, ItemName, I get only 37 records returned:
SELECT ItemCode
,ItemName
,DuplicateCount = COUNT(*)
FROM IQR1
WHERE WhsCode = 01
GROUP BY
ItemCode
,ItemName
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
How do I correctly modify the first query to get multiple columns and still return 38 records?