0

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

错误是 Msg 156, Level 15, State 1, Line 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
4

1 回答 1

0

也许它在你的代码之间有一个你看不到的隐形字符,重写你的脚本很方便,无需选择副本或过去。

于 2015-05-23T08:55:26.940 回答