Skip to content

Conversation

albcunha
Copy link

@albcunha albcunha commented Jul 6, 2020

I was trying to group by a queryset with following stackoverflow answer
from sqlalchemy import func
Table.query.with_entities(Table.column, func.count(Table.column)).group_by(Table.column).all()

But, only the folowing code worked:
queryset = search_test.query()
queryset = queryset.with_entities(Table.column1, func.count(Table.column2)).group_by(Table.column1)
results = queryset.all()

GREAT WORK!!!

I think it needs to close the function.

albcunha added 2 commits July 6, 2020 05:42
I was trying to group by a queryset with following stackoverflow answer
from sqlalchemy import func
Table.query.with_entities(Table.column, func.count(Table.column)).group_by(Table.column).all()

But, only the folowing code worked:
queryset = search_test.query()
queryset = queryset.with_entities(Table.column1, func.count(Table.column2)).group_by(Table.column1)
results = queryset.all() 

GREAT WORK!!!

I think it needs to close the function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant