The below mysql query yeilds the following result:

SELECT COUNT(ProgramType) AS Counter
FROm credential_state
GROUP BY ProgramType;

Results:
Counter
4
7
7

I would like return the max from the above (7). The following query is giving my an error that says: Every derived table must have its own alias. Not sure what I'm doing wrong.

SELECT MAX(Counter) AS MAX FROM(SELECT COUNT(ProgramType) AS Counter
FROm credential_state
GROUP BY ProgramType);

Please HELP!

You can simply pass the Count to the Max function like so:

select max(count(ProgramType)) as MAXCOUNT 
from credential_state 
group by ProgramType
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.