Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 SQL 从该查询中找到平均值:
SELECT count(col1) as count FROM table1 GROUP BY col1 HAVING count > 1
我试图找到每个平均行数col1
col1
到目前为止,我设法找到了每行的总数量col1,现在我只需要 avg
select avg( c ) from ( SELECT count(col1) as c FROM table1 GROUP BY col1 HAVING count > 1 )
对于表,您需要别名并更改count为count(*).
count
count(*)
询问:
SELECT avg(t1.c) AS avgcol1 FROM (SELECT count(col1) AS c FROM table1 GROUP BY col1 HAVING COUNT(*) > 1) t1