hierarchical data - SQL CTE counting childs recursion -


I would like (using whistle) In this way, the children at the original level Number of including their children Is there any sample available?

  create table t_parent (id INT not primary primary key, parentID INT not null) t_parent value INSERT (4, 2) InsertT_parent VALUES (5, 1) INSERT T_parent Value (6, 5) T-Family values ​​in InsertT_parent VALUES (2, 1) InsertT_parent VALUES (1, 0) in (1, 0) T- Enter into family values ​​(7, 5); As with q (Select ID, select all from t_parent UNIUS, Include q from P. ParentID, t_parent p ON p.id = q.parentID) by selection ID, ID (*) ID by ID  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -