Не проверял, как proof of concept
SELECT
p.kod_o,
p.kod_rs,
p.mes,
p.vel
FROM potr p
INNER JOIN
(
SELECT
kod_o "kod",
AVG(vel) "vel"
FROM potr
WHERE god_potr = '2012'
GROUP BY kod_o
) t on t.kod = p.kod_o
and t.vel > p.vel
WHERE 1=1
AND p.god_potr = '2012'
AND p.mes IN (6,7,8)