Thread: Get Counts
View Single Post
  #4 (permalink)  
Old June 10th, 2003, 12:45 AM
KenSchaefer KenSchaefer is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can do this in a single SQL statement. Just use:

SELECT
   StoreID,
   StoreName,
   OrderStatus,
   COUNT(*)
FROM
   Stores
INNER JOIN
   Orders
ON
   Stores.StoreID = Orders.StoreID
GROUP BY
   StoreID, StoreName, OrderStatus
ORDER BY
   StoreID, OrderStatus DESC

Cheers
Ken

www.adOpenStatic.com