Selecting most recent date between two columns

前端 未结 13 1372
再見小時候
再見小時候 2020-12-30 22:15

If I have a table that (among other columns) has two DATETIME columns, how would I select the most recent date from those two columns.

Example:

13条回答
  •  执笔经年
    2020-12-30 23:00

    select ID, 
    case
    when Date1 > Date2 then Date1
    else Date2
    end as MostRecentDate
    from MyTable
    

提交回复
热议问题