sorry if this has been asked and answered before but I have not been able to find an answer that solves me particular problem.
I get the following message when trying to run an ssrs query and I am not sure how to correct it. Normally the error refers to an extra space or whatever that can be picked up from copy and pasting but I can't find it if there is one and I'm not sure what else the problem could be. Here is the error message followed by the query. Any help/comments would be much appreciated
TITLE: Microsoft SQL Server Report Builder
An error occurred while executing the query. Incorrect syntax near '='.
ADDITIONAL INFORMATION:
Incorrect syntax near '='. (Microsoft SQL Server, Error: 102)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=09.00.4060&EvtSrc=MSSQLServer&EvtID=102&LinkId=20476
------------------------------"
SELECT
company.cmp_name
,commodity.cmd_code
,commodity.cmd_name
,IIF(vTTSTMW_ChargeDetails.[Delivery Year]=@DeliveryYear, SUM(vTTSTMW_ChargeDetails.Charge),0) AS [Revenue Current Year]
,IIF(vTTSTMW_ChargeDetails.[Delivery Year]=@DeliveryYear-1, SUM(vTTSTMW_ChargeDetails.Charge),0) AS [Revenue Prior Year]
FROM
company
LEFT OUTER JOIN vTTSTMW_ChargeDetails
ON company.cmp_id = vTTSTMW_ChargeDetails.[Bill To ID]
LEFT OUTER JOIN commodity
ON vTTSTMW_ChargeDetails.[Order CMD Code] = commodity.cmd_code
GROUP BY
company.cmp_name
,commodity.cmd_code
,commodity.cmd_name
IIF
became available in SQL 2012. It is not valid in 2008. – Tab Alleman