Sep-19-2017, 06:06 PM
Hello,
I just cant get group by to work :(
I followed a tutorial: http://flask-sqlalchemy.pocoo.org/2.1/queries/
...and tried to extend it with group_by() unsuccessfully.
I use
Class.query.filter(Class.name=='John').all()
to get my data and everything works fine.
Now, I want for the data to be grouped by Class.surname...
but it doesn't work if I add
group_by(Class.surname)
i.e.:
Class.query.filter(Class.name=='John').group_by(Class.id, Class.surname).all()
Can someone point me to the right direction, please?
I just cant get group by to work :(
I followed a tutorial: http://flask-sqlalchemy.pocoo.org/2.1/queries/
...and tried to extend it with group_by() unsuccessfully.
I use
Class.query.filter(Class.name=='John').all()
to get my data and everything works fine.
Now, I want for the data to be grouped by Class.surname...
but it doesn't work if I add
group_by(Class.surname)
i.e.:
Class.query.filter(Class.name=='John').group_by(Class.id, Class.surname).all()
Can someone point me to the right direction, please?