也许您必须使用聚合函数
max或
min用于列ID。对于分组的列,它将仅返回一个ID。
select max(Id), type, breed from animalsgroup by type, breed
编辑:
其他不同的执行方式:
具有汇总功能
select id, type, breed from animals group by type, breed having id = max(Id)
具有和聚合子查询
select id, type, breed from animals a1group by type, breed having id = ( select max(id) from animals a2 where a2.type = a1.type and a2.breed = a1.breed )



