Reputation: 4665
There are referer records in my database. All records include date,clicks, scrolls, countries etc. And in here, I successfully group referer records and include average values of clicks, scrolls, countries etc. However, I also want to enable date range, like last 3 days.
SELECT *, COUNT(*), COUNT(conv), AVG(clicks), AVG(scrolls),
AVG(spent) FROM track where referid='".$memberr."' GROUP BY
referer ORDER BY ".$sortby." desc limit 0,35
How can I integrate this last 3 days query with my mysql_query above ?
FROM_UNIXTIME(date,'%Y-%m-%d') > CURDATE() - INTERVAL 3 DAY
Upvotes: 0
Views: 296
Reputation: 2722
Pretty simple thing to do, you just need to add another condition:
WHERE date >= DATE_SUB(CURDATE(), INTERVAL 3 DAY) AND date <= CURDATE()
Upvotes: 4