Its probably they way you're retrieving the DateCreated and Total values. Try this:select a.UserID ,a.Domain ,max(DateCreated) DateCreated ,a.Totalfrom tDomainCount a with (nolock)JOIN ( SElect UserID ,Domain ,max(total) Total from tDomainCount e with (nolock) Where Domain IN ( Select top 3 Domain From tDomainCount with (nolock) where UserID = e.UserID order by total desc ) group by UserID, Domain ) b ON a.UserID = b.UserID and a.Domain = b.Domain and a.Total = b.TotalGroup by a.UserID ,a.Domain ,a.Total
Be One with the OptimizerTG