Sql 以id为维度,选不重复的

Sql 以id为维度,选不重复的,第1张

Sql 以id为维度,选不重复信息如下列出SQL语句

方案一:distinct

select distinct name from table

方案二:group by

select min(fid),name,sex from table group by name

方案三:

select * from table where name in(select name from table group by name having count(name)=2)

以上三个语句,能将sql数据库里不重复的信息筛选出来。

select t.* from 表 t

where exists(select * from 表 a where a.第二列 = t.第二列 group by a.第二列 having count(a.第二列) = 1)

你测测吧,给个采纳就行了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10843534.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-11
下一篇 2023-05-11

发表评论

登录后才能评论

评论列表(0条)

保存