5 Answers
5

This is a trick that works in MySQL, as flag=1 will either be True or False. But True = 1 and False = 0 in MySQL so you can add the 1s and 0s using the SUM() function.

Other solutions with IF or CASE would be better for clarity or if there is any chance you want to move the database to another RDBMS.

Comments not related to the question:

It's bad habit to use reserved words like date or count for naming fields or tables.

It's also not good to use "date" when you actually store a timestamp. Names should reflect use.

For table names it's recommended to use singular (post_vote) and not plural - although many use plural, it gets confusing in the end. Plural is good for some fields or calulated fields, like your yes_votes and no_votes where we have a counting.