Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting sub category count
Message
De
06/02/2016 13:14:40
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows 2008 Server
Divers
Thread ID:
01631008
Message ID:
01631010
Vues:
52
>Something like
>
>SELECT COUNT(DISTINCT SubCategoryID) FROM Whatever WHERE CategoryID = 123
>
It is that I need to get the main category fields such as:
SELECT Category.Numero,MIN(Category.Anglais) AS Anglais,COUNT(Category2.Numero) AS Compte
 FROM Category
 LEFT JOIN Category AS Category2 ON Category.Numero=Category2.NoCategory
 WHERE Category.NoClient=78 AND Category.NoCategory=0
 GROUP BY Category.Numero
And, I am trying to avoid the GROUP BY which forces me to use MIN() syntax to collect other fields or to use a sub select.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform