| Posted by ZeldorBlat on 09/08/05 01:13 
First off, you probably can't use the word 'Date' as a column name.Aside from that, it isn't too tough:
 
 Hits today:
 
 select sum(pageViews)
 from tbl_hits
 where Date = curdate()
 
 Hits this week:
 
 select sum(pageViews)
 from tbl_hits
 where weekofyear(Date) = weekofyear(curdate())
 and year(Date) = year(curdate())
 
 If you want to count total hits for some arbitrary interval:
 
 select sum(pageViews)
 from tbl_hits
 where Date between '1/5/2005' and '7/16/2005'
 
 And, if you want to see these broken out by each page, just add
 'pageename' to the select list and add a 'group by pagename' at the end
 of the query.
 [Back to original message] |