sql - 如何显示数据库表中的重复电子邮件计数?

标签 sql

这里,这是我的数据库表结构。

|----|------------------|
|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/

相关文章:

sql - 创建全文索引错误

c++ - SQLINTEGER 的 ODBC 错误

mysql - SQL查询两张表(1-M)

sql - 计算删除SQL Server的顺序

sql - 由于哈希冲突导致的死锁?

sql - TSQL Count 函数和不同的缺失 NULL 值

SQL服务器 : How to sort table names ordered by their foreign key dependency

MySQL:数字格式

sql - 将 SQL Server 数据库转换为本地 C# 数据库

sql - 锁定 Oracle 行,使第二个线程无法读取数据