I have to show how many votes were issued each day (from the first vote to the last vote), users voted for the poll 2 .
My current request is working fine; but I have problems when there are no votes on a particular day. For example, for poll 2, this should be the result of:
- May 11, 2017 = 1
- May 12, 2017 = 0
- May 13, 2017 = 0
- May 14, 2017 = 0
- May 15, 2017 = 0
- May 16, 2017 = 0
- May 17, 2017 = 1
- May 18, 2017 = 0
- May 19, 2017 = 0
- May 20, 2017 = 2
... but instead I get the following:
- May 11, 2017 = 1
- May 17, 2017 = 1
- May 20, 2017 = 2
, , , ( ), . :
SELECT DATE(poll_vote.date_insert) AS date_insert,
COUNT(poll_vote.id_vote) AS q
FROM poll_vote WHERE poll_vote.id_poll = 2
GROUP BY DATE(date_insert) ORDER BY date_insert
SQL Fiddle . !