Counting number of joined rows in left join
How about something like this:
SELECT m.MESSAGEID, sum((case when mp.messageid is not null then 1 else 0 end)) FROM MESSAGE mLEFT JOIN MESSAGEPART mp ON mp.MESSAGEID = m.MESSAGEIDGROUP BY m.MESSAGEID;
The COUNT() function will count every row, even if it has null. Using SUM() and CASE, you can count only non-null values.
EDIT: A simpler version taken from the top comment:
SELECT m.MESSAGEID, COUNT(mp.MESSAGEID) FROM MESSAGE mLEFT JOIN MESSAGEPART mp ON mp.MESSAGEID = m.MESSAGEIDGROUP BY m.MESSAGEID;
Hope that helps.