Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CountDistinct in SQL Server
Message
 
 
À
01/04/2008 11:04:00
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01307343
Message ID:
01307349
Vues:
11
>There is a CountDistinct function in Reporting Services that "Returns the number of non-null unique instances of an item within a set". I would like to do that in a SQL query, but can't seem to find my brain this morning. There are just three items in the query, ItemA, ItemB, and the Number (or count) of unique values for ItemB with respect to itself. In other words, if ItemB had values P1, P3, and P7, and if P1 occurred 347 times, and P3 occurred 231, etc., these values would appear in ColumnC.
>
>All help is appreciated.
SELECT ItemA, COUNT(DISTINCT ItemB ) FROM mytable GROUP BY ItemA
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform