SQL中怎么取编号最大一行

结果应该是合同 编号 产品 数量AA 1 A 200BB 0 B 150
2025-12-15 04:44:57
推荐回答(4个)
回答1:

使用 in字句。

例表tablea, 编号字段位id

sql语句可以这样写:

select * from tablea where id in(select max(id) from tablea)

回答2:

select 表.* from
(select Max(编号) 最大号,合同 from 表 group by 合同) a
inner join 表 on 表.合同=a.合同 and 表.最大号=a.编号

回答3:

回答4:

select * from tb where 编号=(select max(编号) from tb)