0

I have table hits with columns created and user_id.

I want get stats hits count for last 30 days, GROUP BY day. But I have problem, because some days user dont have traffic.

And as a result, I do not see this day in the report.

How to get data for every day (with 0 hits), even where there is no hits?

My query:

SELECT user_id, toDate(created) as date, COUNT() as count
FROM hits
WHERE created > NOW() - INTERVAL 30 DAY
GROUP BY toDate(created), user_id
Alex
  • 65
  • 1
  • 4

0 Answers0