我有一个以这种方式返回结果的SQL查询:
id first_date second_date third_date 1 12-AUG-13 04.41.42.658000000 PM 07-JUL-14 10.24.02.188000000 AM 06-JAN-12 11.20.01.148000000 AM 2 11-AUG-12 04.41.42.658000000 PM 06-SEP-13 09.22.02.188000000 AM 04-FEB-12 11.20.01.148000000 AM
如何获得每行的最低日期,以便以这种方式显示结果?
id lowest_date_for_each_row 1 06-JAN-12 11.20.01.148000000 AM 2 04-FEB-12 11.20.01.148000000 AM
答案 0 :(得分:2)
您可以使用least
功能:
select id, least(first_date, second_date, thrid_date)
from ...
答案 1 :(得分:1)
我认为LEAST功能应该做你想做的事情:
http://www.techonthenet.com/oracle/functions/least.php
类似
SELECT id, LEAST(first_date, second_date, third_date) leastDate FROM datesTable