mysql nested count - how?
Here's the initial query:
SELECT COUNT(column) FROM table GROUP BY column;
This gives me something like the following:
COUNT(column)
2
4
1
1
3
etc.
BUT I need to to count all of those together in one 开发者_StackOverflow社区number! How could I do that? COUNT(COUNT(column))
throws an error: "Invalid use of group function".
P.S. this is not used in any program, if it was, it would be trivial to count them together.remove the group by:
select count(column) from table;
if you need distinct columns:
select count(distinct column) from table; -- might not work in mysql
or:
select count(*) from (select distinct column from table) as columns;
Not sure if this works in mysql: SELECT COUNT(distinct column) FROM table
精彩评论