I have a query which contains both a group by and a count, e.g:

SELECT
   to_char(pa_shopping_cart.delivery_date, 'FMMM/FMDD/YY') AS delivery_date,
   pa_products.product_name AS product_name,
   pa_orders.order_state AS state,
   count(*) AS count
FROM
  pa_shopping_cart,
  pa_products,
  pa_orders
WHERE
  pa_shopping_cart.order_id = pa_orders.order_id AND
  pa_shopping_cart.product_id = pa_products.product_id
GROUP BY
  pa_shopping_cart.delivery_date,
  pa_products.product_name,
  pa_orders.order_state
ORDER BY
  pa_shopping_cart.delivery_date, pa_products.product_name;


This query is really handy because it gives me the count of each
product grouping by delivery within each possible order state.

Here's the question - I would like to get the count of how many tuples are
returned total.  With most queries, count(*) works great for this purpose,
however I need something that will give me the total count of tuples
returned even when there is a grouping.

Any ideas?


Ryan Mahoney


Wed, 19 Jun 2002 15:19:25 -0400 (EDT)
<ryan@paymentalliance.net>
count and group by question