Reputation: 56199
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 ?
Upvotes: 0
Views: 76
Reputation: 289955
What about appending this:
filter_by(type=1)
All together:
for l, c in session.query(Player.level, func.count(Player.level)).\
group_by(Player.level).filter_by(type=1).all()
Upvotes: 2