Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting sub category count
Message
 
 
À
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:
01631013
Vues:
45
>>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.

I'm not sure what you are doing. Why would be more than one record for the same category in Category table?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform