1
好吧,所以我需要將最初用於訪問數據庫的查詢轉換爲將在SQL-Compact Edition數據庫上運行的查詢。IIF to Case翻譯
和查詢我有一個IIF語句(不SQL工作)內
我擡頭一切都表明,我應該用案例時更換。
這是我的原代碼:
Select [OrderNumber], [CustomerName], [PO_TAG], [Shape], [Size], [DrawingNumber],
[OrderBuildTime], [RequiredDateTime], [LatestStatusTime], [ExpectedCompletionDateTime],
[DateImported], Sum(IIF([Status] = 'Printed', PanelBuildTime, 0)) AS OrderBuildTimee from
SteelOrders
INNER JOIN FinalizedPrintedStickers
ON
SteelOrders.OrderNumber = LEFT(FinalizedPrintedStickers.SN,10)
GROUP BY SteelOrders.OrderNumber, [CustomerName], [PO_TAG], [Shape], [Size], [DrawingNumber],
[OrderBuildTime], [RequiredDateTime], [LatestStatusTime], [ExpectedCompletionDateTime],
[DateImported]
這是IIF聲明:
Sum(IIF([Status] = 'Printed', PanelBuildTime, 0)) AS OrderBuildTimee
這是我更換了IIF語句:
Sum(CASE Status WHEN 'Printed' THEN PanelBuildTime ELSE 0) AS OrderBuildTimee
這是代碼的全身看起來像後記:
Select [OrderNumber],
[CustomerName],
[PO_TAG],
[Shape],
[Size],
[DrawingNumber],
[OrderBuildTime],
[RequiredDateTime],
[LatestStatusTime],
[ExpectedCompletionDateTime],
[DateImported],
Sum(CASE Status WHEN 'Printed' THEN PanelBuildTime ELSE 0) AS OrderBuildTimee
From SteelOrders
INNER JOIN FinalizedPrintedStickers
ON
SteelOrders.OrderNumber = LEFT(FinalizedPrintedStickers.SN,10)
GROUP BY SteelOrders.OrderNumber, [CustomerName], [PO_TAG], [Shape], [Size], [DrawingNumber],
[OrderBuildTime], [RequiredDateTime], [LatestStatusTime], [ExpectedCompletionDateTime],
[DateImported]
這是我新的錯誤消息:
Major Error 0x80040E14, Minor Error 25501
> Select [OrderNumber],
[CustomerName],
[PO_TAG],
[Shape],
[Size],
[DrawingNumber],
[OrderBuildTime],
[RequiredDateTime],
[LatestStatusTime],
[ExpectedCompletionDateTime],
[DateImported],
Sum(CASE Status WHEN 'Printed' THEN PanelBuildTime ELSE 0) AS OrderBuildTimee
From SteelOrders
INNER JOIN FinalizedPrintedStickers
ON
SteelOrders.OrderNumber = LEFT(FinalizedPrintedStickers.SN,10)
GROUP BY SteelOrders.OrderNumber, [CustomerName], [PO_TAG], [Shape], [Size], [DrawingNumber],
[OrderBuildTime], [RequiredDateTime], [LatestStatusTime], [ExpectedCompletionDateTime],
[DateImported]
There was an error parsing the query. [ Token line number = 12,Token line offset = 58,Token in
error =) ]
耶,除了我得到一個新的錯誤消息,因爲左邊是不sqlcompact支持-_-。哦,我只是用substring替換它 –
@JustinKirk更新了代碼以使用substring代替 – Taryn