0
点赞
收藏
分享

微信扫一扫

SQL 去除表中字段重复的数据,取唯一值


说明:stable表中name字段的值存在重复(比如有多个tom,但年龄是不一样的),即其它的值不重复,但想取其name唯一的值

select * from stable s1 where id in (select max(distinct id) from stable s2 where s1.name=s2.name ) order by id desc



举报

相关推荐

0 条评论