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

后端 未结 3 1610
离开以前
离开以前 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:34

    In my opinion you are better off doing this type of logic in your code. But if you wanted to do it in pure SQL you could construct a query to give you the results of all the days between one day and the next ... either by inserting into a temp table or an in memory table... then left join that into your results so that you get all the days regardless of if there were results for that day.

提交回复
热议问题