In article <27amdeINNoju@uwm.edu> dbm@csd4.csd.uwm.edu (Dennis B Meilicke) writes:
>How do I count the number of groups returned by a SELECT with a GROUP
>BY clause? SELECT COUNT(*) .... GROUP BY ... will return the number
>of rows in each group. But I want to know the number of groups.
>
>In Oracle, you would use SELECT COUNT( COUNT(*) ) ... GROUP BY ...
>Needless to say, that doesn't work under Informix.
Is that SQL-Standard? I doubt it, but I'm not sure.
>Of course, I'm just missing the obvious. So could someone point me to
>the obvious? :-)
All solutions are obvious, afterwards.
I'd suggest:
SELECT COUNT(DISTINCT group_name) FROM table_name
Dunno, if that is standard, either, but it sure does your job.
Regards,
-svb.
--
Sebastian v. Bomhard, +49-89-298934, +49-89-296629 <svb@muc.de>
St.-Anna-Str. 13, D-80538 Muenchen (Lehel)
>>>>>>>>>>> The early bird catches the EARLY worm. <<<<<<<<<<<<