Filter from the same user times i have a table with user id-s, and many times for the same users, like this:

id    time
1     13:00:01
1     13:00:01
2     13:00:09
1     13:00.23
1     13:00:24
2     13:00:11
2     13:00:11


I would like to get this dataset:

id    time
1     13:00:01
2     13:00:09
1     13:00.23
2     13:00:11


So i would like remove all the rows with the same id-time pair and with the same id, but where the time between the same user times is bigger than 20s. Can anybody help to me? I'm hanging on this problem for 4 days :(
http://sqlfiddle.com/#!9/c88a4/8

select t1.id, t1.t, time_to_sec(t1.t) s
from times t1
left join times t2 on t1.id = t2.id
  and time_to_sec(t1.t) &gt; time_to_sec(t2.t)
  and abs(time_to_sec(t1.t) - time_to_sec(t2.t)) &lt;= 20
where t2.id is null
group by t1.t, t1.id


uses "groupwise-max" method with dynamicaly defined group. Seems to work on your testing data.