hello, i have this structure
i want to extract count of visits (where difference between dates is more than 30 minutes for the same ip).
this should work like this:
125.122.211.11# 2010-03-03 20:51:46#visit = 1
12.123.125.121# 2010-03-03 20:52:46#visit = 2
123.121.54.152# 2010-03-03 20:53:46#visit = 3
125.122.211.11# 2010-03-06 16:00:46#visit = 4
125.122.211.11# 2010-03-06 16:20:46#visit = 4(diff less than 30 minutes)
i try this but not working :(
thanks
Code:
mysql> select id,refer,ip,date from logs; +-----+-------------------------------------------+----------------+---------------------+ | id | refer | ip | date | +-----+-------------------------------------------+----------------+---------------------+ | 354 | http://www.google.com | 125.122.211.11 | 2010-03-03 20:51:46 | | 355 | http://www.google.com | 12.123.125.121 | 2010-03-03 20:52:46 | | 356 | http://bing.com | 123.121.54.152 | 2010-03-03 20:53:46 | | 357 | http://bing.com | 125.122.211.11 | 2010-03-06 16:00:46 | | 358 | http://bing.com | 125.122.211.11 | 2010-03-06 16:20:46 | +-----+-------------------------------------------+----------------+---------------------+
this should work like this:
125.122.211.11# 2010-03-03 20:51:46#visit = 1
12.123.125.121# 2010-03-03 20:52:46#visit = 2
123.121.54.152# 2010-03-03 20:53:46#visit = 3
125.122.211.11# 2010-03-06 16:00:46#visit = 4
125.122.211.11# 2010-03-06 16:20:46#visit = 4(diff less than 30 minutes)
i try this but not working :(
Code:
SELECT date FROM logs WHERE date >= now() - INTERVAL 30 DAY GROUP BY ip HAVING TIMESTAMPDIFF(MINUTE, date, now()) < 30
Comment