我有一个看起来像这样的 WHERE 语句:
WHERE
((@Value1 IS NULL AND [value1_id] IS NULL) OR [value1_id] = ISNULL(@Value1, [value1_id]))
AND
((@Value2 IS NULL AND [value2_id] IS NULL) OR [value2_id] = ISNULL(@Value2, [value2_id]))
AND
((@Value3 IS NULL AND [value3_id] IS NULL) OR [value3_id] = ISNULL(@Value3, [value3_id]))
AND
((@Value4 IS NULL AND [value4_id] IS NULL) OR [value4_id] = ISNULL(@Value4, [value4_id]))
AND
((@Value5 IS NULL AND [value5_id] IS NULL) OR [value5_id] = ISNULL(@Value5, [value5_id]))
AND
((@Value6 IS NULL AND [value6_id] IS NULL) OR [value6_id] = ISNULL(@Value5, [value6_id]))
我需要在 WHERE 中添加一些条件逻辑,以便我可以使用 Value5 和 Value6 做一些特殊的事情。基本上,如果 Value5、Value6 或其他值为 null,我想按原样使用 Value 5 和 Value 6 行。如果所有三个值都不为 NULL,我需要对这些值进行一些计算。
关于最佳行动的任何想法?