SELECT COUNT(*) AS count
, DATE(date)
, SUM(flag = 1) AS yes_votes
, SUM(flag = 2) AS no_votes
FROM post_votes
WHERE date > '2010-07-01'
GROUP BY DATE(date)
This is a trick that works in MySQL since there flag=1will be either Trueor False. But True = 1also False = 0in MySQL, so you can add 1 and 0 using a function SUM().
Other solutions with IFor CASEwill be better for clarity or if you want to move the database to another DBMS.
Comments not related to the issue:
date count .- "", . .
- (
post_vote), , , . , yes_votes no_votes, .