Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting sub category count
Message
From
06/02/2016 13:14:40
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows 2008 Server
Miscellaneous
Thread ID:
01631008
Message ID:
01631010
Views:
48
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform