5 回答

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個贊
個人認(rèn)為
??? select city, no_orders, upto_two_orders, more_than_two_orders
??? form (select c.customerid,city,
??? case
??? when COUNT(orderid)=0 then 'no_orders'
??? when COUNT(orderid)<=2 then 'upto_two_orders'
??? when COUNT(orderid)>2 then 'more_than_two_orders'
??? end as category
??? from dbo.Customers as c
??? left outer join dbo.Orders as o
??? on c.customerid=o.customerid
??? group by c.customerid,city) <--在這之前應(yīng)該沒錯這后面這個as是給誰附別名為D呢所以這該有錯->as d
???<--這個地方PIOVT不知道是什么 沒見過--> PIOVT(COUNT(customerid) for
??? category in ([no_orders],[upto_two_orders],[more_than_two_orders])) as p;
- 5 回答
- 0 關(guān)注
- 574 瀏覽
添加回答
舉報