select
date_format(from-unixtime(poster_time),'%y-%m'),
(select id_member from messages as msg2 where date_format(from-unixtime(msg1.poster_time),'%y-%m')=date_format(from-unixtime(msg2.poster_time),'%y-%m') group by concat(date_format(from-unixtime(poster_time),'%y-%m'), id_member) order by max(count(msg2.id_member)) desc limit 1)
from messages as msg1
group by date_format(from-unixtime(msg1.poster_time),'%y-%m')
Возможно как-то так
Или с количество сообщений
select
date_format(from-unixtime(poster_time),'%y-%m'),
(select concat(id_member,'-',count(msg2.id_member)) from messages as msg2 where date_format(from-unixtime(msg1.poster_time),'%y-%m')=date_format(from-unixtime(msg2.poster_time),'%y-%m') group by concat(date_format(from-unixtime(poster_time),'%y-%m'), id_member) order by max(count(msg2.id_member)) desc limit 1) as member_and_messages
from messages as msg1
group by date_format(from-unixtime(msg1.poster_time),'%y-%m')
но надо будет разрезать member_and_messages. Иначе без второго вложенного запроса не достать и то и другое
Еще проще
<?php
for($i=12;$i>0;$i--)
{
$date = date('y-m',strtotime("-{$i} month"));
$query = "select id_member, max(count(id_member)) as posts from messages where date_format(from-unixtime(poster_time),'%y-%m') = '{$date}' group by id_member limit 1";
}