How to add filter to group_by query
I need to find number of level of specific type in database.
for l, c in session.query(Player.level, func.count(Player.level)).group_by(Player.level).all() # how to add condition Player.type==1
I have seven different type for player and I have 10 levels. I need to get number of players by level which are only type=1 (not to list all seven)
How to add filter to this query ?
What about appending this:
for l, c in session.query(Player.level, func.count(Player.level)).\ group_by(Player.level).filter_by(type=1).all()