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 ?

Answers


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()

Need Your Help

Network on Main Thread exception while trying to send e-mails in Android without user intervention

java android networkonmainthread

I tried to implement the sending of emails without user intervention as explained in a post that's open for this issue:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.