If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Count Distinct (Per day) IP Addresses for a date range
Hi,
I am looking for some help to create a mysql query to get the distinct (per day) count of ip addresses a link has been clicked for a date range.
Lets say my IP address clicks on the same link 5 times every day during January 2012 using the same ip address. There would be 155 (5*31) records in the table but the query result should display 31 as we are only counting the same ip address max of once per day.
SELECT COUNT(*) AS distinct_count
FROM ( SELECT DISTINCT
ip
, DATE(clickdate)
FROM daTable
WHERE clickdate >= '2012-01-01'
AND clickdate < '2012-02-01' ) AS t
did you test the last query i gave you? how is it different than what you really wanted?
Sorry I was looking for something like your first query which I have listed below but to also include the link column.
Code:
SELECT COUNT(*) AS distinct_count
FROM ( SELECT DISTINCT
ip
, DATE(clickdate)
FROM daTable
WHERE clickdate >= '2012-01-01'
AND clickdate < '2012-02-01' ) AS t