select - How to calculate the number of immediate children for each node in an adjacency list -


I have the sorted data that I am using in the proximity list model.

If possible, I want to do it in the same selection, like generating a result ...

  Results ... ID Title Child Count 1 Test 1 10 2 Test 2 2 3 Test 3 etc ...  

Thanks for your advice!

without title,

  select parents as ID Make the number of children in the form of COUNT (ID) by the table group by the parents  

If you want the title, I think that you can join yourself (perhaps slow) :

  select as t1.ID id, as t1.Title title, COUNT (T.ID) as the child Table T1 join the left OUTER table T2 on T1 .ID = t2.parentID  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -