Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Incorrect syntax near the keyword 'ELSE'

Author  Topic 

Darts75
Starting Member

27 Posts

Posted - 2014-11-10 : 23:49:22
Hi Everyone,

I am receiving the error message 'Incorrect syntax near the keyword 'ELSE'.' from the query section below -

CASE WHEN T3.LineTotal IS NULL THEN ((T0.Rate * SUM(T0.LineTotal)) - ((T0.DiscPrcnt / 100)) ELSE (((T0.Rate * SUM(T0.LineTotal)) - (T0.DiscPrcnt / 100)) + T3.LineTotal) END AS 'Total NATIVE'


If anybody can suggest how to fix this error it will be greatly appreciated.

Kind Regards,

David

AASC
Starting Member

24 Posts

Posted - 2014-11-11 : 00:43:48
There were only one extra bracket in case statment

CASE WHEN [T3].LineTotal IS NULL
THEN ( ( [T0].Rate * SUM([T0].LineTotal) ) - ( [T0].DiscPrcnt
/ 100 ) )
ELSE ( ( ( [T0].Rate * SUM([T0].LineTotal) ) - ( [T0].DiscPrcnt / 100 ) )
+ [T3].LineTotal )
END AS 'Total NATIVE'
Go to Top of Page

Darts75
Starting Member

27 Posts

Posted - 2014-11-11 : 16:29:55
Thank you AASC, a simple oversight - but one that was causing me considerable torment!
Go to Top of Page
   

- Advertisement -