I have searched many topics and didn’t find the answer, or question was too complex. So okay. This is my first question.
Here is the SQL
SELECT parent.*,
(
SELECT COUNT(*)
FROM child
WHERE parent.id = child.parent_id
)
FROM parent
How to do this clause in sqlalchemy?
WHERE ui.invited_by = u.id
Can it be reproduced in collections ? sql expressions ?
P.S. I know that it can be done by group_by. But i need by subquery.
Thank you.
I find here really awesome answer. But too also too complicated. First of all i want to tell that closure in sql world is CORRELATION.
This is NOT the same but helps me.