Is there an general way to get the number of distinct values of a variable for the total and in each group of a group by clause with a single query. I am using Oracle 8.<BR><BR>SELECT COUNT(DISTINCT a), .,... FROM fromclause WHERE whereclause GROUP BY groupbyclause.<BR><BR>SELECT COUNT(DISTINCT a) FROM fromclause WHERE whereclause.<BR><BR>I need the total count and the group counts. The fromclause and whereclause are exactly the same for the two queries. The queries are sometimes very expensive because the database is very large and the fromclause, whereclause and orderbyclause are generated dynamically and may be very complicated. If I could just read the same blocks once with a single query I would likely reduce the query time about in half.