日期:2014-05-17 浏览次数:20812 次
字段1 字段2 …… id name 1 a 2 b 3 c 4 c 5 b 6 ……
select id,name from ( select id,name,row_number(partition by 分组键 order by 排序键) rn ) where rn=1;
------解决方案--------------------
--假设table为t --第一个sql select * from t where rowid in (select max(rowid) from t group by t.name) order by id; --第二个sql select id,t.name,t2.cou from t,(select name,count(name) cou from t group by name ) t2 where t.name=t2.name order by t.id;
------解决方案--------------------
order by t2.cou;
------解决方案--------------------