Function in SQL Server 2008 similar to GREATEST in mysql?

前端 未结 5 1382
孤独总比滥情好
孤独总比滥情好 2020-11-27 22:11

I want to find the maximum value of multiple columns.

MySQL supports the GREATEST function but SQL Server doesn\'t.

Is there any function similar to this in

5条回答
  •  盖世英雄少女心
    2020-11-27 22:53

    I would recommend the following solution:

    SELECT (CASE WHEN t.createdt < t.changedt THEN t.changedt ELSE t.created END) AS ChgDate
      FROM table t
    

提交回复
热议问题