sql server - Cannot use a derived table in WHERE subquery -
why can't use d in subquery?
select * dbo.orders d (select count(*) d) = 11;
that's not valid syntax... if was, you'd no results unless there 11 rows in orders table.
i'm guessing you're looking following...
with cte_ordercount ( select *, ordercount = count(*) on (partition o.customerid) dbo.orders o ) select * cte_ordercount oc oc.ordercount = 11;
Comments
Post a Comment