开发者

Select the minimum of two dates

I want to do the following:

SELECT min( date_1, date_2)
from dual;

But this will fail terribly because min only takes on开发者_StackOverflow社区e parameter. Is there another way?


SELECT LEAST(date_1, date_2) FROM DUAL;

Oracle LEAST


Try using CASE instead of MIN to compare the two and return the smaller value:

   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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜