如何从这样的内部查询中总结一列?显然这不起作用,但它本质上是我想要做的。这里有很多类似的帖子,但这是独一无二的,因为我的帖子有HAVING
。
SELECT SUM(cnt)
FROM
(
SELECT COUNT(*) as cnt
FROM users
GROUP BY email
HAVING COUNT(*)>1
)
答案 0 :(得分:1)
如果你有查询的别名,你写的内容应该有用
SELECT SUM(cnt)
FROM
(
SELECT COUNT(*) as cnt
FROM users
GROUP BY email
HAVING COUNT(*)>1
) as t