id, date_start, date_end, text
1, '2016-01-01 11:00:00', '2016-03-01 11:52:00', 'task 1'
2, '2016-01-03 11:00:00', '2016-01-05 11:52:00', 'task 2'
3, '2016-01-04 11:00:00', '2016-01-07 11:52:00', 'task 3'
4, '2016-01-10 11:00:00', '2016-01-15 11:52:00', 'task 4'
[task 1]=========================================================[/task 1]
[task 2]========[/task 2]
[task 3]===========[/task 3]
[task 4]========[/task 4]
day, count
2016-01-01, 1
2016-01-02, 1
2016-01-03, 2
2016-01-04, 3
2016-01-05, 3
2016-01-06, 2
2016-01-07, 2
2016-01-08, 1
2016-01-09, 1
2016-01-10, 2
....
2016-03-01, 1
2016-03-02, 0
select selected_date, (select count(1) from tasks where selected_date between date_start and date_end) cnt from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where selected_date between (select min(date_start) from tasks) and (select max(date_end) from tasks)