如果子查询中的另一个值小于某个值或 null,我正在尝试更新列:
UPDATE
Customer
SET
PriceClassID = 'A'
FROM
(
SELECT
custid,
SUM(curybaldue) as last_sum
FROM
SOShipHeader
WHERE
OrdDate > @year_ago
AND
Status = 'C'
GROUP BY
CustID
) a
JOIN Customer ON Customer.CustId = a.CustId
WHERE
( last_sum < 3000 OR last_sum IS NULL )
AND
PriceClassID IN ('CLUB', 'CLUB-E')
AND
Customer.User7 <= @year_ago
AND
Customer.User7 > @year_and_month_ago
但是,当我检查是否PriceClassID
已更改时,我发现 last_sum 为空的任何行都没有更改。我究竟做错了什么?