1

我有这个可以在我的数据库中找到所有重复项:

SELECT phone, count(*) AS ct FROM table GROUP BY `phone` HAVING ct >1

这会产生 12 行,但是这 12 行的 ct 之和等于 26:

phone      ct
3600000000  4
3602931205  2
3602933399  2
3602933736  2
3602936241  2
3602937911  2
3602939287  2
3602939353  2
3602939767  2
3603174530  2
3606612300  2
3608995913  2

如何修改查询以告诉我 ct 的总数?

4

1 回答 1

2

试试这个::

Select SUM(temp_1.count_1) as totalCount
from
(
SELECT phone, count(1) AS count_1 FROM table GROUP BY `phone` HAVING count_1 >1) as temp_1
于 2012-12-04T17:21:33.450 回答