![](/img/trans.png)
[英]How to debug a SQL query that results in an error “Incorrect syntax near 'for'”?
[英]getting error in Sql Query incorrect syntax near ')'
執行此查詢時出現錯誤
消息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
您的CASE
需要END
SUM(CASE WHEN SIHDR.[Currency Factor]=0 THEN SILIN.[Selling Price] ELSE SILIN.[Selling Price] END) as Selling_Price_INR
這是因為第二個case
語句中缺少end
。
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_]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.