您没有指定正在使用的数据库,但是应该可以使用以下数据库:
select t1.id, t1.streetname, t1.countfrom yourtable t1inner join( select id, max(count) max_count from yourtable group by id) t2 on t1.id = t2.id and t1.count = t2.max_count
请参阅带有演示的SQL
Fiddle。注意,您将必须
count使用MySQL的反引号或数据库使用的任何字符来转义保留字来转义列名。我的建议是避免对列和表名使用保留字。



