首页 新闻 会员 周边 捐助

sqlserver2005的问题

0
[已解决问题] 解决于 2011-03-18 11:36

    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;

请高手帮我看看那里错了,谢谢

技术新手的主页 技术新手 | 初学一级 | 园豆:125
提问于:2011-03-16 16:17
< >
分享
最佳答案
0

两处错误:

第二行的Form应为" From"

倒数第二行的PIOVT应为"PIVOT"

英文差害人不浅,啊········

邀月 | 高人七级 |园豆:25475 | 2011-03-16 19:28
谢谢您啊,真尴尬,请您以后多帮助我,我是新手
技术新手 | 园豆:125 (初学一级) | 2011-03-18 11:36
@
技术新手:呵呵。欢迎交流
邀月 | 园豆:25475 (高人七级) | 2011-03-18 11:40
其他回答(2)
0

报什么错?

写代码的小2B | 园豆:4377 (老鸟四级) | 2011-03-16 17:07
关键字 'as' 附近有语法错误。

可奇怪我了,我跟书上写的都不对
支持(0) 反对(0) 技术新手 | 园豆:125 (初学一级) | 2011-03-16 17:08
0

个人认为

    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;

小w威 | 园豆:37 (初学一级) | 2011-03-16 17:18
也谢谢您
支持(0) 反对(0) 技术新手 | 园豆:125 (初学一级) | 2011-03-18 11:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册