Re: Counting time in a stats table

From: Date: Sat, 30 Dec 2000 06:14:08 +0000
Subject: Re: Counting time in a stats table
Groups: php.db 
Request: Send a blank email to php-db+get-5540@lists.php.net to get a copy of this message
Addressed to: "Stuart McDonald" <stuart@fourelephants.com> php-db@lists.php.net ** Reply to note from "Stuart McDonald" <stuart@fourelephants.com> Fri, 29 Dec 2000 09:14:40 +0700 > > Hi all, > > I've got a table that records cookie information, with the columns ID > (md5), Time(timestamp) and referer(varchar) > > What I want to do is run a query that will group the time values by > date and count them (ignoring the referer so that I can get total > number of visitors per day. > > So, the way I figure it, the query needs to format all the date > entries so that it strips off the time (thus giving me just the date > of the visit) - I can use DATE_FORMAT() for that, then I need to > count the values for each of these days and display the result - > unfotunately I can't get the counting to work. > Try something like: SELECT COUNT(*) AS Count, DATE_FORMAT( Time, '%Y%m%d' ) AS Time FROM table GROUP BY Time ORDER BY Count This gives you a table with count and time with that count, sorted by count. You can change the ORDER BY clause to change the order. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.db (#5540) next »