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

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -