SQL 查询一个字段所有的之出现次数大于2的条数

现有字段 Name
张三
张三
李四
王五
王五
王五
赵六
赵六
其中 在这个字段中除了李四 其余的三个人都出现了最少两次 怎样才能用一条语句就可以查出来同一人在Name 字段中出现的的次数大于1的 最终要得到的结果是3 麻烦各位了 先谢了。数据并不仅仅是这几条 而且Name的 值也不知道

with tmp(Name) as(
select '张三' union all
select '张三' union all
select '李四' union all
select '王五' union all
select '王五' union all
select '王五' union all
select '赵六' union all
select '赵六')
 
select count(*) from (
select Name from tmp group by Name having count(*)>1
) t

结果为:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-09-06
select name,count(*) from table_name group by name having count(*)>1;

第2个回答  推荐于2017-04-22
select count(name) ,name from table group by name having count(name)>1本回答被提问者采纳