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
精彩评论