I think that this has to be done as 2 queries. If you group on all fields then when accounts are equal but other fields are not then you will still get the output.
One query just selects the account when profile is max, then this joins to the other query to select the records.
Brian