我想从另一列的日期条件更新一列。
DECLARE @FIRSTDATE DATE ='2016-11-01';
DECLARE @LASTDATE DATE ='2016-11-30';
UPDATE A
SET A.Status = CASE
WHEN B.Date IS NULL THEN 0
ELSE 1
END,
A.DESCRIPTION = CASE
WHEN B.Date IS NULL
THEN 'UNPAID'
WHEN B.Date BETWEEN @FIRSTDATE AND @LASTDATE
THEN 'CARRY FORWORD'
ELSE
'PAID'
END
FROM TABLE1 AS A
JOIN TABLE2 AS B ON A.ID = B.ID;