I am experiencing some strange behaviour and I really don't have test date/ environments, so Will this query return top 5 rows ordered by count, or will it take top 5 rows and sort them then. What would be the query for the first?
select top 5 l.userId, count(*) "count" from Log l
where ...
group by l.userId
order by "count" desc