开发者

Select the minimum of two dates

开发者 https://www.devze.com 2023-01-24 01:36 出处:网络
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

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

精彩评论

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