删除重复数据保留id最大那条

2014-11-24 12:59:42 · 作者: · 浏览: 0

select b.id,b.username

from test b

where b.id not in (select max(t.id) as id

from test t

having count(t.username) > 1

group by t.username)

and b.username in (select t.username

from test t

having count(t.username) > 1

group by t.username);

作者 joe_zhjiang