Possible Duplicate:
Getting the minimum of two values in sql
I'm trying to get all values between a range. I'm doing something like this
DECLARE @StartSeq INT
set @StartSeq = (select Sequence from MyTbl where ...)
update ... and MyCol between @StartSeq and @StartSeq+@RelativePosition
But if RelativePosition is negative it fails because its a smaller amount then startseq. The easiest solution I can think of is duplicate my code and doing an if (RelPos<0) to see if I want to do @StartSeq+@RelativePosition first or second. However that doesn't seem like the best solution. Is there a way i can do it in sql? I tried min(a,b) but it doesnt work in sql.