Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting sub category count
Message
 
 
To
07/02/2016 00:38:09
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:
01631025
Views:
48
>>Can you post the structure of the table(s) involved here to determine when category has subcategories?
>
>Category table
>
>Numero Primary key
>Title Character(20)
>NoCategory Category primary key
>
>So, basically, this is recursive inside the same table.
>
>So, an unlimited number of categories can have parents and so on.
>
>For most of them, Category.NoCategory is 0 so that denotes a parent. That is the highest hierarchy.
>
>Then, for those records having a value in Category.NoCategory, it means they are child records of the parent. The parent can also be a child of another parent.

So, do you want to count all subcategories or just top level subcategories? In the former case we're talking about recursive CTE.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform