Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicate select syntax
Message
 
To
21/09/2005 09:35:11
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
01051610
Message ID:
01051621
Views:
8
This message has been marked as the solution to the initial question of the thread.
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform