My goal is to change the where clause depending on a variable.
For example if @value > 0 my where should be
sampletable.column1 = 1 and sampletable.column2 = @value2
If @value = 0 my where should be
sampletable.column1 = 1 and sampletable.column2 > 0
I am looking for something like
declare @value as integer
set @value = 1
select * from sampletable where sampletable.column1 = 1 and
sampletable.column2 = case
when @value>1 then @value
else > 0
end
For example if @value > 0 my where should be
sampletable.column1 = 1 and sampletable.column2 = @value2
If @value = 0 my where should be
sampletable.column1 = 1 and sampletable.column2 > 0
I am looking for something like
declare @value as integer
set @value = 1
select * from sampletable where sampletable.column1 = 1 and
sampletable.column2 = case
when @value>1 then @value
else > 0
end