>I am trying to list all of the duplicates of a data pair. I am trying:
>
>SELECT TOP 100 PERCENT COUNT(dbo.License.SerialNumber + dbo.License.LicenseKey) AS countKey,
> dbo.License.SerialNumber + ' ' + dbo.License.LicenseKey AS pair
>FROM dbo.License INNER JOIN
> dbo.License License_1 ON dbo.License.SerialNumber + dbo.License.LicenseKey = License_1.SerialNumber + License_1.LicenseKey
>GROUP BY dbo.License.SerialNumber + ' ' + dbo.License.LicenseKey
>HAVING (COUNT(dbo.License.SerialNumber + dbo.License.LicenseKey) > 1)
>ORDER BY countKey
>
>But the countKey item returns the same number for every item. I have verified this is incorrect. What am I doing wrong, or rather, what would be the best way to accomplish this?
SELECT dbo.License.SerialNumber, dbo.License.LicenseKey, COUNT(*) AS Cnt
FROM dbo.License
HAVING COUNT(*) > 1
GROUP BY 1,2
ORDER BY 1,2
(not tested)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.