I’m trying to get unique views per IP, counted max 1 time per day returned using a MySQL query.
The table is looking like this:
product_id time ip
INT TIMESTAMP VARCHAR
The query should return the unique views for any time, but it should filter product id’s so each product have it’s own unique views field counted. The IP-address in the table should be counted MAX once per day. I’ll give you some details what should and should not be counted in the query below:
product_id DATE(time) ip should_be_counted
11 2012-12-14 1.1.1.1 YES
11 2012-12-14 1.1.1.2 YES
11 2012-12-14 1.1.1.1 NO
11 2012-12-13 1.1.1.1 YES
11 2012-12-13 1.1.1.1 NO
Should be returned:
product_id unique_views
11 3
This is what I want:
product_id unique_views
11 103
8 53
2 3
1 1
Which means that the query should use ORDER BY unique_views DESC.
Thanks for helping!
1 Answer