MySQL: get MAX or GREATEST of several columns, but with NULL fields

后端 未结 4 2221
刺人心
刺人心 2020-12-07 22:24

I\'m trying to select the max date in three different fields in each record (MySQL) So, in each row, I have date1, date2 and date3: date1 is always filled, date2 and date3 c

4条回答
  •  孤城傲影
    2020-12-07 23:04

    COALESCE your date columns before you use them in GREATEST.

    The way you handle them will depend on how you want to deal with NULL.. either high or low?

提交回复
热议问题