读书人

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

发布时间: 2012-07-22 19:31:17 作者: rapoo

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

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);

读书人网 >其他数据库

热点推荐