@fromValue FLOAT; @toValue FLOAT;
SELECT *
FROM INVOICE
WHERE TOTAL > @fromValue and TOTAL < @toValue
我有一个带有TOTAL列的INVOICE表。我想在这样的组合框中选择3个条件:
答案 0 :(得分:1)
您可以传递以下变量:
DECLARE @fromValue DECIMAL(18,4), @toValue DECIMAL(18,4);
SET @fromValue = 500 ; -- depending on initial value
--SET @toValue = NULL;
SELECT *
FROM INVOICE
WHERE TOTAL BETWEEN ISNULL(@fromVALUE,0) AND ISNULL(@toValue,9999999);
答案 1 :(得分:0)
我一定错过了什么,因为它看起来太简单了?
SELECT
*
FROM
Invoice
WHERE
Total < 100 OR Total Between 100 and 200 OR Total > 500
答案 2 :(得分:0)
我无法想象或明白你需要什么,但如果你想传递两(2)个值并使用它,那么:
SELECT *
FROM INVOICE
WHERE TOTAL BETWEEN @fromValue AND @toValue;