Hi.
Is there a processing difference between these two queries? It looks like the first example is doing the count twice and the second query is doing the count once and then displaying the people with more than one order. On a large table is one way more efficient than the other.
select name, count(orderID) as Num
from orders
group by name
having count(orderID) > 1
order by name
or
;with cte as
(select name, count(orderID) as Num
from orders
group by name)
select * from cte
where num > 1
order by name