All pastes #404444 Raw Edit

Something

public text v1 · immutable
·published 2007-03-21 00:41 UTC
rendered paste body
SELECT t1.*, count(t2.id_route) cnt
  FROM (SELECT *  FROM calls ORDER BY call_start LIMIT 0,1000) as t1
  LEFT JOIN (SELECT *  FROM calls ORDER BY call_start LIMIT 0,1000) as t2
    ON t1.id_route = t2.id_route AND
       (t1.call_start, t1.id_call, t1.duration) <= (t2.call_start, t2.id_call, t2.duration)
 GROUP BY t1.id_call, t1.duration
 HAVING cnt <= 3;