Oracle最新日期问题

时间:2016-10-11 15:48:11

标签: oracle date max

我试图在以下选择语句中找到最大值(日期)并收到错误...有人可以帮忙吗?

SELECT MAX(STMT_DATE) < STMT_CLOSE_DATE as "lastdate"
  FROM STMT_FACT;

2 个答案:

答案 0 :(得分:1)

SELECT MAX(STMT_DATE) as "lastdate"
FROM STMT_FACT
WHERE STMT_DATE < STMT_CLOSE_DATE

答案 1 :(得分:0)

To get only Max date:-
  SELECT MAX(STMT_DATE) as "lastdate" FROM STMT_FACT WHERE STMT_DATE < STMT_CLOSE_DATE

To get complete row which contains latest date:-
  SELECT STMT_DATE as "lastdate", [Rest of the columns] FROM (SELECT STMT_DATE FROM 
  STMT_FACT WHERE STMT_DATE < STMT_CLOSE_DATE ORDER BY STMT_DATE DESC) WHERE rownum=1;