如何使用SQL查找此查询的平均值:
SELECT count(col1) as count FROM table1 GROUP BY col1 HAVING count > 1
我正在尝试查找每col1
到目前为止,我设法找到每col1
行的总行数,现在我只需要平均值
答案 0 :(得分:2)
select avg( c )
from ( SELECT count(col1) as c FROM table1 GROUP BY col1 HAVING count > 1 )
答案 1 :(得分:0)
对于表格,您需要别名并将count
更改为count(*)
。
查询:
SELECT avg(t1.c) AS avgcol1
FROM
(SELECT count(col1) AS c
FROM table1
GROUP BY col1 HAVING COUNT(*) > 1) t1