oracle 选择两个日期中的最小值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4137776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:53:08  来源:igfitidea点击:

Select the minimum of two dates

oracle

提问by Scott

I want to do the following:

我想做以下事情:

SELECT min( date_1, date_2)
from dual;

But this will fail terribly because min only takes one parameter. Is there another way?

但这会非常失败,因为 min 只接受一个参数。还有其他方法吗?

回答by Jeffrey Kemp

SELECT LEAST(date_1, date_2) FROM DUAL;

Oracle LEAST

甲骨文最少

回答by Colin O'Dell

Try using CASEinstead of MINto compare the two and return the smaller value:

尝试使用CASE而不是MIN比较两者并返回较小的值:

   SELECT CASE WHEN date_1<date_2 THEN date_1 ELSE date_2 END FROM dual;

Source: http://www.techonthenet.com/oracle/functions/case.php

来源:http: //www.techonthenet.com/oracle/functions/case.php