mysql查看重复id_获取mysql中不同重复ID的计数

这是查询

select count(*),

ss.pname,

ttu.user_id,

ttl.location_name ,

group_concat(em.customer_id),

count(em.customer_id)

from seseal as ss,

track_and_trace_user as ttu,

track_and_trace_location as ttl,

eseal_mapping as em

where ss.real_id=em.e_id

and em.user_id=ttu.user_id

and ttu.location_id=ttl.location_id

group by ss.pname, ttu.user_id, ttl.location_name

having count(em.customer_id)>1 ;

以下是结果:

+----------+----------------+---------+---------------+------------------------------+-----------------------+

| count(*) | pname | user_id | location_name | group_concat(em.customer_id) | count(em.customer_id) |

+----------+----------------+---------+---------------+------------------------------+-----------------------+

| 6 | Nokia N91 | 1 | Malad | 60,51,60,51,58,58 | 6 |

| 2 | SUPERIA 1000gm | 4 | Raichur | 51,46 | 2 |

| 5 | SUPERIA 1000gm | 5 | west bengal | 51,46,51,51,46 | 5 |

| 2 | SUPERIA 500gm | 4 | Raichur | 59,59 | 2 |

| 3 | SUPERIA 500gm | 5 | west bengal | 59,46,59 | 3 |

+----------+----------------+---------+---------------+------------------------------+-----------------------+

现在问题是,正如您在结果集中看到的那样,某些行中的第二个最后一列,customer_id是重复的,并且在某些行中是唯一的.最后一栏是给出了它的计数.

现在我想要的是选择第3行,有两个客户ID,即51和46,这些在该行中是重复的,所以我这行的最后一列应该包含2.

类似地,对于最后一行,我的最后一列应该包含1,因为只有一个客户ID是重复的,即59.

因此,如果您了解确切的问题,那么第二行不应该是此结果集的一部分,因为它不包含任何重复的客户ID.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值