I’m trying to figure out a single sql statement to remove duplicate records from a table but allowing up to 10 duplicates.
I can do the following query to find these duplicates, but I have no idea what query to do to remove all but the first 10 duplicates:
SELECT
ip,
date,
count(ip) as count
FROM
table
WHERE
date
BETWEEN
'2012-02-03 00-00-00'
AND
'2012-02-03 23:59:59'
group by
ip
having
count > 10
I’m not sure if this is even possible, can someone help me out?
Try this:
It uses some kind of sequentially row numbering, please mind that it’s going to work only if pair
dateandipis unique.