select * from xxxxxxx where id in (select max(id) from xxxxxxx where AAAA='0000 ' group by BBBB)
xxxxxxx 为表名
AAAA 为表中的列名(也是该sql语句中的条件列)
BBBB 为有重复数据的列名
max(id) 为取重复数据中id最大的那条数据
如果要取第一条数据,可以用 min(id)
select * from xxxxxxx where id in (select max(id) from xxxxxxx where AAAA='0000 ' group by BBBB)
xxxxxxx 为表名
AAAA 为表中的列名(也是该sql语句中的条件列)
BBBB 为有重复数据的列名
max(id) 为取重复数据中id最大的那条数据
如果要取第一条数据,可以用 min(id)