SELECT DISTINCT the data is distinct but not being filtered [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this questionTrying 开发者_如何学编程to track AdWords visits cause lots of click fraud.
Problem is log is overzealous so often times it will record 2 visits for 1. This is noticable to the eye since the two time
's and ip
's are identical. Just having trouble translating it to SQL.
This is returning 2+ clicks for when the IP matches and the time matches.
SELECT DISTINCT wmf24_statpress.time, count(ip) AS clicks, ip
FROM wmf24_statpress
WHERE urlrequested LIKE '%gclid=%'
GROUP BY ip
Just add time
to your GROUP BY
clause and you should be fine:
SELECT `time`, count(ip) AS clicks, ip
FROM wmf24_statpress
WHERE urlrequested LIKE '%gclid=%'
GROUP BY `time`, ip
Also, you don't need the distinct
clause
Group by both time and ip to remove duplicates and still see repeats, i.e.
SELECT wmf24_statpress.time, count(ip) AS clicks, ip
FROM wmf24_statpress
WHERE urlrequested LIKE '%gclid=%'
GROUP BY wmf24_statpress.time, ip
精彩评论