SELECT * FROM (SELECT * FROM countersRecords ORDER BY id DESC) AS gagaga GROUP BY gagaga.counter_id
SELECT * FROM countersRecords GROUP BY counter_id ORDER BY id ORDER BY id DESC
select max(id) as id
from t
group by counter_id
select * from t
where id in (
select max(t2.id)
from t t2
group by t2.counter_id
)