3
我想用持有比較運營商如'='
,'>'
,'>='
一個參數,並在使用它在那裏用「的情況下,當再」或if語句聲明類似如下:傳遞比較運營商WHERE子句
WHERE
case @Operator
when '=' then (@Amount is null) or (@Amount = 0) or (Amount= @Amount)
when '>' then (@Amount is null) or (@Amount = 0) or (Amount> @Amount)
when '>=' then (@Amount is null) or (@Amount = 0) or (Amount>= @Amount)
END
感謝。但我想知道是否可以爲運算符['BETWEEN'] [@Amount]和[@ Amount2] – user1692483
再添加一個案例謝謝我自己做了WHERE 或者[@Amount]和CASE [@Operator]之間的金額WHEN'在'THEN [@ Amount2] END – user1692483
@ user1692483之間是金額列INT? –