select R.* from Ratings R INNER JOIN (select Account, max(mRating) as MaxRatingForAccount from Ratings GROUP BY Account) Mx ON R.Account = Mx.Account and R.mRating = Mx.MaxRatingForAccountthere's some stuff in here that I haven't used before, like R.* and INNER JOIN and also Mx ON R. etc.,