Hi @Yash90.B
Please check this:
DECLARE @JUN_STDATE NVARCHAR(8),@JUN_ENDDATE NVARCHAR(8),@SEN_STDATE NVARCHAR(8),@SEN_ENDDATE NVARCHAR(8)
SELECT @JUN_STDATE = STDATE FROM #DRNUMBER WHERE CLASS='1TC' AND ROLE='JUNIOR';
SELECT @JUN_ENDDATE = ENDDATE FROM #DRNUMBER WHERE CLASS='1TC' AND ROLE='JUNIOR';
SELECT @SEN_STDATE = STDATE FROM #DRNUMBER WHERE CLASS='1TC' AND ROLE='SENIOR';
SELECT @SEN_ENDDATE = ENDDATE FROM #DRNUMBER WHERE CLASS='1TC' AND ROLE='SENIOR';
UPDATE #DRNUMBER
SET ROLE = CASE WHEN "STDATE" BETWEEN @JUN_STDATE AND @JUN_ENDDATE AND "ENDDATE" BETWEEN @JUN_STDATE AND @JUN_ENDDATE THEN 'JUNIOR'
WHEN "STDATE" BETWEEN @SEN_STDATE AND @SEN_ENDDATE AND "ENDDATE" BETWEEN @SEN_STDATE AND @SEN_ENDDATE THEN 'SENIOR'
END
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.