I want the count of my table data having in date range 7 days before from now. So I have tried this query :
SELECT DATE(leads_update_on), IFNULL(COUNT(*),0) leads 
    FROM tbl_leads 
    WHERE project_id=4 
    AND DATE(leads_update_on) >= DATE_SUB('2016-05-11', INTERVAL 6 DAY) 
    GROUP BY DATE(leads_update_on)
But it returns following result :
       `DATE(leads_update_on)|leads
       ----------------------|-----
       2016-05-06            |    7
       2016-05-07            |    4`
Since other dates does not have any data but I want the result like below if there is no data in specific date :
       `DATE(leads_update_on)|leads
       ----------------------|-----
       2016-05-05            |    0
       2016-05-06            |    7
       2016-05-07            |    4
       2016-05-08            |    0
       2016-05-09            |    0
       2016-05-10            |    0
       2016-05-11            |    0`
What I have to change in my sql query so that I can find the above result. Any help will be appreciated. Thanks in advance.
Sample Input as requested :
    `DATE                |id
   ----------------------|-----
   2016-05-06            |    1
   2016-05-07            |    2
Here only two data is present so for others dates it should return 0 value. It should output like this :
       `DATE(date)           |leads
       ----------------------|-----
       2016-05-05            |    0
       2016-05-06            |    1
       2016-05-07            |    1
       2016-05-08            |    0
       2016-05-09            |    0
       2016-05-10            |    0
       2016-05-11            |    0`
But using this query :-
SELECT DATE(`date`), IFNULL(COUNT(*),0) leads FROM test where DATE(`date`) >= DATE_SUB('2016-05-11', INTERVAL 6 DAY) GROUP BY DATE(`date`)
It returns below result which I don't want:
       `DATE(date)           |leads
       ----------------------|-----
       2016-05-06            |    1
       2016-05-07            |    1`
 
    