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