Sorry, should be
select unique(serviceid),max(msgdate) from messagearchive group by serviceid;