Re: Counting groups?
Posted in 1993
dennis,
>
> 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? :-)
>
> Thanks...
>
> Dennis
>
one way using isql:
select column,
count(*) cnt
from table
group by column
into temp t1;
select count(*) from t1;
regards,
+----------------------------------------------------------------------------+
| . . | |
| ... ... | Bob Baskett |
| ..... ..... | Software Engineer, DBA |
| .. ... .. | Business Systems Integration Group |
| . . . | Semiconductor Products Sector |
| | Mesa, AZ |
| Motorola, Inc. | |
+----------------------------------------------------------------------------+
| 'connectionLESS IS MORE' -- Data Broker |
+----------------------------------------------------------------------------+
| Duct tape is like the force. It has a light side, and a dark side, and |
| it holds the universe together ... |
| -- Carl Zwanzig |
+----------------------------------------------------------------------------+