开发者

SQL Server CASE statement error: Incorrect syntax near '<'

I am trying to convert:

  • any number less than 0 to a -1.
  • any number greater than or equal to 0 to a 1.

My statement is:

SUM(CASE [Apr] WHEN ([Apr] < 0) THEN -1 WHEN ([Apr] >= 0) THEN 1 ELSE NULL END) as Apr

[Apr]开发者_Python百科 is an int which accepts Nulls.

Any ideas why this is not working?


Remove [Apr] after CASE when doing comparisions in WHEN

SUM(CASE WHEN ([Apr] < 0) THEN -1 WHEN ([Apr] >= 0) THEN 1 ELSE NULL END) as Apr


Get ride of the [Apr] after CASE.


SUM(CASE WHEN ([Apr] < 0) THEN -1 WHEN ([Apr] >= 0) THEN 1 ELSE NULL END) as Apr

Lose the [Apr] after Case

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜