how to use count(*) in "group by" queries

Giganews Newsgroups
Subject: how to use count(*) in "group by" queries
Posted by:  renozu (reno…@yahoo.com)
Date: 21 Nov 2006

I am trying to use count(*) to prevent queries from executing that are
blowing out memory. The query comes in two forms:
(1) select a, b, c, d from x, y, z where...;
which I can count first like this:
select count(*) from x,y,z where...;  ==> easy enough

The other form is:
(2) select count(*), a, b, max(c), max(d) from x,y,z where... group by
a,b;
this query already has a count(*), which counts the number of rows in
each group. How can I count the number of groups that will be returned
without actually doing the full query?

Thanks,
Martin

Replies