Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
Select t1.cat_id, t1.id, t2.* from (Select cat_id, min(id) from table group by cat_id UNION Select cat_id, min(id) from table where id not in (Select min(id) from table group by cat_id) group by cat_id) t1 left join table t2 on t1.id = t2.id