compare int and return 1

时间:2017-04-06 16:43:34

标签: sql sql-server

I am trying to compare these 2 fields,

select(@var1-@var2-@var3-@var4),@var6 

and in my mind, I have something like this

if (@var1-@var2-@var3-@var4)>@var6
then return 1
else return 0

How can I do this in SQL?

1 个答案:

答案 0 :(得分:1)

Select case when (@var1-@var2-@var3-@var4)>@var6 then 1 else 0 end