我试图在以下选择语句中找到最大值(日期)并收到错误...有人可以帮忙吗?
SELECT MAX(STMT_DATE) < STMT_CLOSE_DATE as "lastdate"
FROM STMT_FACT;
答案 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;