I have a qry (attached) that is taking forever to run. Can anyone look to see where the problem lies? It really runs into trouble with the Order By. If I take out the group by and the order by statement, it works great, it just doesn't order it right (obviously).
Thanks in advance!
RTRIM(r.No) as CarNumber,
From Passings p with (nolock) inner join Results r with (nolock)
Inner Join Timelines t
p.Pit = 0
passingtime in (SELECT max(i.passingtime) FROM passings i with (NOLOCK) WHERE
i.ResultItemID = p.ResultItemID
AND i.passingtime >=0
AND i.DecoderID<> 0)--(Select Top 1 DecoderID From Timelines where IsLapCounter=1))
Group by p.ResultItemID,
Order By t.TrackOrder Desc, p.ElapsedTIme