0

如何从这样的内部查询中总结一列?显然这不起作用,但它本质上是我想要做的。有很多类似的帖子,但这是独一无二的,因为我有一个HAVING条款。

SELECT SUM(cnt)
FROM
    (
        SELECT COUNT(*) as cnt
        FROM users
        GROUP BY email
        HAVING COUNT(*)>1
    )
4

1 回答 1

1

如果您有查询的别名,您所写的内容应该可以工作

SELECT SUM(cnt)
FROM
    (
        SELECT COUNT(*) as cnt
        FROM users
        GROUP BY email
        HAVING COUNT(*)>1
    ) as t

SQL小提琴

于 2012-11-27T16:21:55.147 回答