我來自MySQL後臺,請在這裏忍受我。使用MSSQL Server 2008,我正在編寫一個查詢,其中包含IFF語句。我收到以下錯誤。IFF聲明錯誤'='附近的語法不正確
"Msg 102, Level 15, State 1, Line 8
Incorrect syntax near '='."
我的查詢看起來是這樣的:
SELECT
a.[storeno],
a.[Description],
a.[transactiondate],
a.[amount] AS 'pos',
b.[amount] AS 'ecc',
a.[amount] - b.[amount] AS 'difference',
IIF(a.amount = b.amount,'BALANCED','UNBALANCED') AS 'result',
GETDATE()
FROM
[POS_REPORT].[dbo].[Txn_Daily_Totals] a
LEFT JOIN
[POS_REPORT].[dbo].[SAP_FI_INBOUND_DAILY_TOTALS] b ON
a.[storeno] +
a.[transactiondate] =
b.[storeno] +
b.[transactiondate]
我已經嘗試了很多不同的方式,並不能得到這個權利。我已使用
IF
BEGIN
END
ELSE
END
和案例。所有給我不同的錯誤。請幫幫我。
可能重複的[你如何在SQL SELECT中執行IF ... THEN?](http://stackoverflow.com/questions/63447/how-do-you-perform-an-if-then- in-an-sql-select) – hims056