1

I have a query like this

SELECT DATE(date) AS DateOnly, COUNT(DISTINCT(device_id)) AS nrUnique 
FROM `mytable`
WHERE date>='2013-10-04 18:32:04' and date<now()
GROUP BY DateOnly 
order by DateOnly

result

2013-10-05 | 10
2013-10-08 | 5

I want to generate a result like this

2013-10-04 | 0
2013-10-05 | 10
2013-10-06 | 0
2013-10-07 | 0
2013-10-08 | 5

I've do this in postgresql using a union like this

....
UNION
(SELECT 0 as count, date(generate_series('2013-10-04 18:32:04'::date, now(),'1 day')) as timestamp))

How I can do this with MYSQL?

mikiamomik
  • 43
  • 2
  • 8

0 Answers0