You can not use
ORDER BY clause in a sub-query. Remove/comment the ORDER BY clause in the inner query. However you can use
ORDER BY along with
SELECT TOP.. though.
select logstep,logdate,min(MinOflogTime),max(MaxOflogTime) from
(
SELECT l.logStep,l.LOGDATE,Min(l.logTime) AS MinOflogTime, Max(l.logTime) AS MaxOflogTime
FROM TBLLOG9800 l
GROUP BY l.logStep,l.LOGDATE
)
group by logstep, logdate
ORDER BY logStep;
Hope, it helps :)