hi there.. depending on your database the syntax could not be the same..
but the idea is:
select b.departmentname,a.datacount,a.departmentid from(
select count(*) as datacount,departmentid from studentmessage group by departmentid) as a inner join departmentmessage as b on a.departmentid = b.departmentid
this will give you all the records, to find the first just order and get only the first one (select top 1 (SQL server, access), where rownum < 2 (ORACLE))
Note that the instruction could be a little wrong I don't have a way to test it...
Read this if you want to know how to get a correct reply for your question:
^^Took that from dparsons signature and he Took that from planoie's profile
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
I know that CVS was evil, and now i got the proof: