Asked By – Nazmul Hasan
I want a “group by and count” command in sqlalchemy. How can I do this?
Now we will see solution for issue: Group by & count function in sqlalchemy
The documentation on counting says that for
group_by queries it is better to use
from sqlalchemy import func session.query(Table.column, func.count(Table.column)).group_by(Table.column).all()