user198989
user198989

Reputation: 4665

mySQL - How can I integrate this "last 3 days only" query

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.

enter image description here

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

Answers (1)

Aida Paul
Aida Paul

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

Related Questions