1

我在 case 语句中的大于运算符上遇到错误。我在这里想念什么?

DECLARE @ODS_LOAN_MAXDATE DATE, @MAX_MAINTENANCE DATE, @MAX_TRANS DATE, @ODS_LOAN_Count int 

SELECT @MAX_MAINTENANCE = MAX(DATE_MAINTENANCE_LAST) FROM FISERV_ODS..LOAN_MASTER_FILE
SELECT @MAX_TRANS = MAX(DATE_TRANS_LAST) FROM FISERV_ODS..LOAN_MASTER_FILE

SELECT CASE @ODS_LOAN_MAXDATE
    WHEN @MAX_MAINTENANCE > @MAX_TRANS
        THEN @MAX_MAINTENANCE
    ELSE @MAX_TRANS 
END 
FROM FISERV_ODS..LOAN_MASTER_FILE
4

1 回答 1

3

语法应该是:

SELECT CASE WHEN @MAX_MAINTENANCE > @MAX_TRANS
        THEN @MAX_MAINTENANCE
    ELSE @MAX_TRANS 
END 
于 2013-01-31T22:10:05.043 回答