I'm writing a query in SQLite
, for Android
, with a schema like this (extremely simplified here, just the fields I need)
GROUP
group_id primary_key,
parent_group_id nullable
PERSON
person_id primary_key,
parent_group
I need to count the number of person
s in a group
and in its descendant group
s, given the group_id
of the group
I want to count for. I think I need a CTE query and I've been reading all morning about them, but I'm not grasping how they work.