0

I am trying to get the AMOUNT_APP WHERE DATE _APP is the greatest value.

I wrote this query, but I am having troubles

SELECT AMOUNT_APP
FROM Payments_App
WHERE DATE_APP = MAX(DATE_APP)

I expect to get 5234.34

My Table

Albert Gunter
  • 45
  • 1
  • 4

2 Answers2

0

Use order by and rownum:

select pa.amount_app
from (select pa.*
      from payments_app
      order by date_app desc
     ) pa
where rownum = 1;

Or keep can be quite efficient:

select max(pa.amount_app) keep (dense_rank first order by date_app desc)
from payments_app;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

If we suppouse that DATE_APP is an attribute that you could find the most recently updated results.

select AMOUNT_APP FROM Payments_App WHERE DATE_APP = (Select MAX(DATE_APP) FROM Payments_App) ;

Jeil
  • 37
  • 1
  • 7