SQL-使用MAX获得价值

时间:2018-07-16 18:56:41

标签: sql oracle11g greatest-n-per-group

我正在尝试获取AMOUNT_APP,其中_APP是最大的价值。

我写了这个查询,但是遇到了麻烦

SELECT AMOUNT_APP
FROM Payments_App
WHERE DATE_APP = MAX(DATE_APP)

我希望能获得5234.34

My Table

2 个答案:

答案 0 :(得分:0)

使用'<' not supported between instances of 'float' and 'NoneType' def test(): market_price = None low_price = None try: if market_price < low_price: market_price = low_price except TypeError: if market_price is None: market_price = 0. elif low_price is None: low_price = 0. if market_price < low_price: market_price = low_price return market_price print(test())

order by

或者rownum可能非常有效:

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

答案 1 :(得分:0)

如果我们认为DATE_APP是可以找到最新更新结果的属性。

  

从Payments_App中选择 AMOUNT_APP ,在 DATE_APP =(选择   MAX( DATE_APP )from Payments_App);