1

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 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.

2 Answers 2

3

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;
Sign up to request clarification or add additional context in comments.

Comments

1

Not sure if this works in mysql: SELECT COUNT(distinct column) FROM table

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.