怎么能查询id出现两次的行的数量,比如这里一共有4个出现两次的?

0

3A4AF9E835A1C4A2515CA305C9DA65B0.png

 
已邀请:
0

老头子 - 专注是唯一的捷径 2016-11-01 回答

大于2次的呢?比如3次的需要吗?
嵌套2次count来获取重复数据
 
select count(*) from (
select id,count(*) as n from table group by id
) where n = 2
0

- 取是能力,舍是境界 2016-11-01 回答

如果只是查数量
select count(*) from (
select id from tablename group by id having count(*) = 2) as t

要回复问题请先登录注册