我有一个如下所示的存储过程;当我通过时NULL
,Gkol
我希望将其更改为尽可能少的数量(存在于表中),但它没有发生 - 为什么会这样?
ALTER PROCEDURE sp_vUnitsUnitTejariGetFilteredUnitDetail
(@UnitFB BIT,
@UnitWithCooking BIT,
@MMofidFrom FLOAT = NULL,
@MMofidTo FLOAT = NULL,
@GKolFrom FLOAT = NULL,
@GKolTo FLOAT = NULL)
AS
BEGIN
DECLARE @MMofidCalculative BIT
DECLARE @GKolCalculative BIT
IF (@MMofidFrom IS NULL)
SELECT @MMofidFrom = MIN(MMofid)
FROM vw_PSA_UnitsUnitTejari
IF (@MMofidTo IS NULL)
SELECT @MMofidTo = MAX(MMofid)
FROM vw_PSA_UnitsUnitTejari
IF (@GKolFrom IS NULL)
SELECT @GKolFrom = MIN(GKol)
FROM vw_PSA_UnitsUnitTejari
IF (@GKolTo IS NOT NULL)
SELECT @GKolTo = MAX(GKol)
FROM vw_PSA_UnitsUnitTejari
SELECT *
FROM vw_PSA_UnitsUnitTejari
WHERE UnitTypeID = 1
AND UnitStateID = 1
AND UnitFB = ISNULL(@UnitFB, UnitFB)
AND UnitWithCooking = ISNULL(@UnitWithCooking, UnitWithCooking)
AND MMofid BETWEEN @MMofidFrom AND @MMofidTo
AND GKol BETWEEN @GKolFrom AND @GKolTo
END