执行此查询时出现错误
消息102,级别15,状态1,第15行')'附近的语法不正确。
我找不到错误原因。请帮助我查询中的问题
Select
SIHDR.[Posting Date],
SIHDR.[Bill-to Contact No_],
SIHDR.[Order No_],
SILIN.[Bom Item No_],
ISNULL(CONVERT(varchar (30),(Select Description from [Item] where No_ = SILIN.[Bom Item No_])),''),
SILIN.[No_],
SILIN.[Line No_],
CONVERT(varchar (30),SILIN.[Description]),
CONVERT(varchar (30),SILIN.[Description 2]),
CONVERT(varchar (30),SILIN.[Description 3]),
SILIN.[Subscription Starting Date],
SILIN.[Subscription End Date],
SUM(CASE WHEN SIHDR.[Currency Factor]=0 THEN SILIN.[Selling Price] ELSE SILIN.[Selling Price]) as Selling_Price_INR
FROM [Sales Shipment Header] as SIHDR
INNER JOIN [Sales Shipment Line] as SILIN on SIHDR.No_ = SILIN.[Document No_]
enter code here
答案 0 :(得分:0)
您的CASE
需要一个END
SUM(CASE WHEN SIHDR.[Currency Factor]=0 THEN SILIN.[Selling Price] ELSE SILIN.[Selling Price] END) as Selling_Price_INR
答案 1 :(得分:0)
这是因为第二个end
语句中缺少case
。
Select
SIHDR.[Posting Date],
SIHDR.[Bill-to Contact No_],
SIHDR.[Order No_],
SILIN.[Bom Item No_],
ISNULL(
CONVERT(varchar (30),
(Select Description from [Info Edge (India) Ltd$Item] where No_ = SILIN.[Bom Item No_])
),''),
SILIN.[No_],
SILIN.[Line No_],
CONVERT(varchar (30),SILIN.[Description]),
CONVERT(varchar (30),SILIN.[Description 2]),
CONVERT(varchar (30),SILIN.[Description 3]),
SILIN.[Subscription Starting Date],
SILIN.[Subscription End Date],
SUM(
CASE WHEN SIHDR.[Currency Factor]=0
THEN SILIN.[Selling Price]
ELSE SILIN.[Selling Price]
END ---- this end is missing in your query.
) as Selling_Price_INR
FROM [Sales Shipment Header] as SIHDR
INNER JOIN [Sales Shipment Line] as SILIN on SIHDR.No_ = SILIN.[Document No_]