SQL Server T-SQL CASE错误

时间:2012-07-09 19:00:03

标签: tsql sql-server-2000

我在使用T-SQL(SQL Server 2000)的CASE上收到错误。任何反馈都非常感谢

  

错误是消息156,级别15,状态1,行2语法不正确   关键字'CASE'。

- 查询如下:

select c.name,c.customerid,c.linkid
      ,case when c.linkid=x.linkid then x.orderitem end as orderitem
      ,case when c.linkid=x.linkid then x.orderdate end as orderdate
from customer as c
Inner join 
(
    Select C.CustomerID, C.LinkID, O.OrderItem,O.OrderDate
    From Customer as C
    JOIN Orders as O 
        ON C.CustomerKey=O.OrderKey
    WHERE O.OrderDate='mm-dd-yyyy'
) as X
    on c.customerid=x.customerid
order by c.customerid
        ,case when c.linkid=x.linkid then 0 else 1 end asc
        ,c.linkid

1 个答案:

答案 0 :(得分:0)

也许它在你看不到的代码之间有一个看不见的字符, 无需复制或过去即可重写你的scrpit。