[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Web Page Hit Counter
I am trying to log activity on a web site and then display the activity. I want to be able to break it down by hour eventually. Right now I would like to get the total hits and the
hits for today. I have created a table like the one below.
create table hits (page_id INTEGER, htime DATETIME);
I can then use the queries below to get the information.
Total hits on page
Select page_id, count(*) as hcount from hits group by page_id order by page_id
Hits today on page
Select page_id, count(*) as hcount from hits where DAYOFYEAR(now())=DAYOFYEAR(htime) group by page_id order by page_id
My question is there a way to perform both queries at one time and generate a table with both total and daily information. One problem is the the returned table have a
different number of rows, because page X might not have been accessed today. This means it does not show up in the second table. If both queries are done together the
daily count show be 0, in the combined table.
Also, I looked in the manual and could not find anywhere wether GROUP BY orders the data based on the grouping or do I need the ORDER BY clause.
Hope this is clear.
Thanks
Edward
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <mysql-thread69181@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
This mailing list archive is a service of Copilot Consulting.