Filling Gaps in Dates Returned from Database - pure SQL solution possible?

后端 未结 3 1612
离开以前
离开以前 2020-12-20 04:22

I have this query:

SELECT COUNT(*) as clicks, DATE_FORMAT(FROM_UNIXTIME(click_date), \'%w %M %Y\') as point 
FROM tracking 
WHERE click_date < $end_date A         


        
3条回答
  •  清歌不尽
    2020-12-20 04:30

    I'd stick to PHP logic, looping between the lowest date and the highest date, and incrementing one day at a time.

    You could probably do it in SQL with some fancy joins, but I won't even start to consider that nastiness!

    BTW, %w is the day of the week, starting 0=Sunday. You probably wanted %d.

提交回复
热议问题