I can\'t seem to find a relevant example out there.
I\'m trying to return a sub-set of a table, and for each row in that table, I want to check how many children it has,
Your queries all assume that the order that the parent child nodes are entered is sequential. If a child from one of the first nodes is entered at the end and its ID or PK is higher, then the query doesn't work.