Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

Re: [PHP-DB] Counting time in a stats table From: Stuart McDonald (stuart <email protected>)
Date: 12/31/00

worked like a dream - thankyou verymuch

Stuart
----- Original Message -----
From: <php3 <email protected>>
To: Stuart McDonald <stuart <email protected>>; <php-db <email protected>>
Sent: Saturday, December 30, 2000 1:14 PM
Subject: Re: [PHP-DB] Counting time in a stats table

Addressed to: "Stuart McDonald" <stuart <email protected>>
              php-db <email protected>

** Reply to note from "Stuart McDonald" <stuart <email protected>> 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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>