This code works great for getting both a summary of individual Group counts and a Grand Total combined, but I only want the Grand Total of individual countries with no ROLLUP:
SELECT country, count( * )
FROM mytable
GROUP BY country
WITH ROLLUP
LIMIT 0 , 300
Researching a lot of examples, I was hoping this one would finally work but no joy (can't figure out what the MySQL error is in the code):
SELECT country,COUNT(*)
FROM mytable
GROUP BY country
COMPUTE Sum(Count(*))
Thanks for any assistance!
-stucko
If you want to get the number of rows returned by a GROUP BY
you can do something like this
SELECT COUNT(*) FROM (
SELECT country, count( * )
FROM mytable
GROUP BY country
) a /*derived tables need an alias*/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.