这里,这是我的数据库表结构。
|----|------------------|
|SN | Email |
|----|------------------|
|1 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e4f4f6e49434f4742004d4143" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
|2 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e98888a98e84888085c78a8684" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
|3 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="30525270575d51595c1e535f5d" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
|4 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e5c5c7e59535f5752105d5153" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
|5 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a0c2c2e0c7cdc1c9cc8ec3cfcd" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
|6 | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e48787a48389858d88ca878b89" rel="noreferrer noopener nofollow">[email protected]</a> |
|----|------------------|
我想以这种方式显示行:
SN 电子邮件 DuplicateCount
1 [email protected] 2
2 [email protected] 3
3 [email protected] 1
请建议我如何使用 SQL 来显示重复的电子邮件。
最佳答案
您可以使用count
来获取它:
select email, count(email) as duplicates from
tableName group by email order by duplicates desc
关于sql - 如何显示数据库表中的重复电子邮件计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57018262/