Is Null Greater Than Any Date Data Type?

后端 未结 3 1065
傲寒
傲寒 2021-02-12 12:49

I have this query in DB2

SELECT * FROM SOMESCHEMA.SOMETABLE WHERE SYSDATE > @A

If the SYSDATE is NULL, would it be

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-12 13:21

    You can use this solution for comparing of two nullable dates (P.EndDate,C.EndDate):

    [MinDate] =
            CASE
                WHEN
                    ISNULL(C.EndDate,P.EndDate) <= ISNULL(P.EndDate,C.EndDate) 
                THEN
                    ISNULL(C.EndDate,P.EndDate)
                ELSE
                    ISNULL(P.EndDate,C.EndDate)
            END
    

提交回复
热议问题