We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subq = 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()
Error when trying to create a subquery
Executable SQL or text() construct expected, got <sqlalchemy.sql.selectable.Subquery at 0x7f5cac0da990; t2>.
trying this use case: https://stackoverflow.com/questions/45775724/sqlalchemy-group-by-and-return-max-date
Linux
No response
0.0.4
3.7.9
The text was updated successfully, but these errors were encountered:
You could try to execute the two queries in one exec call
exec
subq = 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()
Sorry, something went wrong.
No branches or pull requests
First Check
Commit to Help
Example Code
Description
Error when trying to create a subquery
Executable SQL or text() construct expected, got <sqlalchemy.sql.selectable.Subquery at 0x7f5cac0da990; t2>.
trying this use case: https://stackoverflow.com/questions/45775724/sqlalchemy-group-by-and-return-max-date
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.7.9
Additional Context
No response
The text was updated successfully, but these errors were encountered: