Count clicks in date range with SQL (PHP) -
i want count clicks based on daily level date range.
let's want count clicks between "2013-05-01" - "2013-05-30" , want following result this:
date clicks 2013-05-01 50 2013-05-02 60 2013-05-03 65 2013-05-04 0 etc...
at moment i've following sql call
select count(date) clicks, date views uid = $id group date order date desc
this working fine, problem is, don't days in date range, days there clicks. should able days, days there 0 clicks.
hope can help
since getting results days there clicks, won't results days no clicks. need either
a) generate list of dates , return number of clicks each day. similar sql server: how select days in date range if no data exists days
b) instead of using resulting rows output, enumerate each day in php , insert 0 entry output if day not found in sql result set. can use date_add add 1 day @ time period start datetime
, format string date check against result's date.
Comments
Post a Comment