sql单表中某一字段重复,取最近3条或几条数据

select a.* from tablename a left join tablename b on a.uid=b.uid and a.id>=b.id group by a.id,a.name,a.uid having count(b.id)<=3 order by a.uid,a.id;

sql查询语句,针对需求:一个表中某一字段是有重复的数据,针对该字段相同的值只取最近的3条或要求的几条;

 

 

              --记录铭心!

posted @ 2016-01-26 18:16  struggle-way  阅读(1619)  评论(0编辑  收藏  举报