如果你有2个字段的表:
ID | AMOUNT
如何使用1个查询获得最大值(AMOUNT)和最后输入记录的数量(按ID desc排序)?
感谢你
答案 0 :(得分:1)
select amount as last_amount,
(select max(amount) from your_table) as max_amount
from your_table
order by id desc
limit 1
答案 1 :(得分:0)
你可以这样做:
SELECT
(SELECT MAX(amount) FROM table) as Max,
(SELECT amount FROM table ORDER BY id DESC LIMIT 1) as Last