Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicate select syntax
Message
From
21/09/2005 11:22:08
 
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
01051610
Message ID:
01051668
Views:
7
>>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)

thank you. It worked with only a little manipulation:

SELECT SerialNumber, LicenseKey, COUNT(*) AS Cnt
FROM dbo.License
GROUP BY SerialNumber, LicenseKey
HAVING (COUNT(*) = 1)
Thank You

Rollin Burr

Politicians and diapers have one thing in common. They should both be changed regularly, and for the same reason.
Previous
Reply
Map
View

Click here to load this message in the networking platform