1

如果您有包含 2 个字段的表:

身份证 | 数量

您如何使用 1 个查询获得最大(AMOUNT)和最后输入的记录的数量(按 id desc 排序)?

感谢您

4

2 回答 2

1
select amount as last_amount, 
      (select max(amount) from your_table) as max_amount
from your_table
order by id desc
limit 1
于 2012-11-16T16:32:02.330 回答
0

你可以这样做:

SELECT
    (SELECT MAX(amount) FROM table) as Max,
    (SELECT amount FROM table ORDER BY id DESC LIMIT 1) as Last
于 2012-11-16T16:34:31.610 回答