Hello,
I am trying to translate this SQL to a SQLAlchemy query, but failed so far:
select `users`.`name`, `assignments`.`id`,
(
select count(*)
from `assignments`
where `assignments`.`user_id` = `users`.`id`
) as `num_assignments`
from `users`
join `assignments`
on `assignments`.`user_id` = `users`.`id`
I would like to get results of (user_id, assignment_id,
total_assignments_per_user_id). I have found a similar question on the
list (https://groups.google.com/forum/#!topic/sqlalchemy/LBEyRe3w-8Q),
and tried to assemble a query like so, but I am missing something...
It would also be nice if there were a faster way to do this. Maybe
someone has a good idea.
And a question on terminology: is it really called subquery if the
"subquery" is in the "select block" (like above).
Many thanks
Sebastian
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.