为了账号安全,请及时绑定邮箱和手机立即绑定

sqlserver2005的问题

sqlserver2005的问题

牛魔王的故事 2018-12-06 18:30:45
    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) as d    PIOVT(COUNT(customerid) for    category in ([no_orders],[upto_two_orders],[more_than_two_orders])) as p; 请高手帮我看看那里错了,谢谢
查看完整描述

5 回答

?
眼眸繁星

TA贡献1873条经验 获得超9个赞

报什么错?

查看完整回答
反对 回复 2019-01-07
?
胡说叔叔

TA贡献1804条经验 获得超8个赞

关键字 'as' 附近有语法错误。

可奇怪我了,我跟书上写的都不对
查看完整回答
反对 回复 2019-01-07
?
郎朗坤

TA贡献1921条经验 获得超9个赞

个人认为

    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) <--在这之前应该没错这后面这个as是给谁附别名为D呢所以这该有错->as d
   <--这个地方PIOVT不知道是什么 没见过--> PIOVT(COUNT(customerid) for
    category in ([no_orders],[upto_two_orders],[more_than_two_orders])) as p;

查看完整回答
反对 回复 2019-01-07
?
Smart猫小萌

TA贡献1911条经验 获得超7个赞

也谢谢您
查看完整回答
反对 回复 2019-01-07
  • 5 回答
  • 0 关注
  • 532 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信