equivalent for .subquery('t2') sqlalchemy #1504
Answered
by
alhoo
movaldivia
asked this question in
Questions
-
First Check
Commit to Help
Example Codesubq = session.exec(select(User.user_id,
func.max(User.created_at).label(
'maxdate'))
.group_by(User.user_id).subquery('t2'))
query = session.exec(select(User).join(subq, and_(
User.user_id == subq.c.user_id,
User.created_at == subq.c.maxdate))).all() DescriptionError when trying to create a subquery
trying this use case: https://stackoverflow.com/questions/45775724/sqlalchemy-group-by-and-return-max-date Operating SystemLinux Operating System DetailsNo response SQLModel Version0.0.4 Python Version3.7.9 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
alhoo
Jun 1, 2022
Replies: 1 comment 1 reply
-
You could try to execute the two queries in one
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
YuriiMotov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could try to execute the two queries in one
exec
call