Date |Thu, 26 Jul 2001 18:56:04 +0100
>From |"Graham Nichols" <[EMAIL PROTECTED]>
Hello!
GN> Hi,
GN> I'm using MYSQL version 3.22.32. I have read that from version 3.23.xx COUNT
GN> can be used in combination with DISTINCT. However, I have a project deadline
GN> which does not give me time to upgrade.
GN> I have a small table 'web-stats' consisting of the following fields:
GN> IP_address
GN> web_date
GN> web_time
GN> web_referer
GN> browser
GN> page
GN> I am using a PHP script to insert entries into this table as a rudimentary
GN> hit counter.
GN> My current syntax is
GN> select web_date, dayofmonth(web_date) as d, count (IP_address) as c from
GN> web_stats group by d order by web_date
GN> but what I actually want is to count the unique IP addresses for each date.
GN> How can I work around this please?
GN> kind regards, Graham Nichols.
Hello.
You just need to read documentation more carefully.
http://www.mysql.com/doc/G/r/Group_by_functions.html
COUNT(DISTINCT expr,[expr...])
Returns a count of the number of different non-NULL values:
So, IMHO your query need to modify like this
SELECT web_date, dayofmonth(web_date) AS d, COUNT (DISTINCT IP_address) AS c
FROM web_stats GROUP BY d ORDER BY web_date
___________________________________________________________________
For technical support contracts, visit https://order.mysql.com/
This email is sponsored by SWSoft, http://www.asplinux.ru/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Grigory Bakunov <[EMAIL PROTECTED]>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB / SWSoft
/_/ /_/\_, /___/\___\_\___/
<___/ www.mysql.com
---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php