Re: Counting groups? (fwd)
Posted in 1993
>From Dennis B Meilicke:
*
* 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.
*
* Of course, I'm just missing the obvious. So could someone point me to
* the obvious? :-)
Try:
SELECT COUNT( UNIQUE field_to_group ) FROM table_name
Hope this helps,
Robert Minter |Data Systems Support| \\\\\\_///
Programmer, Software Development | Orange, CA | ( _ _ )
internet: rob@dssmktg.com | Tel: 714.771.0454 | (| ^ |)
bangpath: uunet.uu.net!dssmktg!rob| Fax: 714.771.3028 | \\`-'/
I used to not know, now I know I don't know. \\_/