Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Duplicate select syntax
Message
 
À
21/09/2005 09:35:11
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01051610
Message ID:
01051621
Vues:
14
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform