摘要: 方法1:使用distinct方法2:使用ROW_NUMBER()函数如:select * from (select ROW_NUMBER() over(Partition by name order by ID asc) as rowid,t.*from t) t1where t1.rowid=1解释:Partition by(根据姓名排重) name order by ID(根据ID排序) asc此段SQL的意思为。只取ROWID为1的数据。因为ROWID通过ROW_NUMBER()函数获取的。如果NAME 相同的有几位,where t1.rowid=1为限定条件,只取第一位。 阅读全文
posted @ 2012-04-12 11:09 Jack.G 阅读(1064) 评论(0) 推荐(0) 编辑