20 pts.
 Record Count Crystal Reports 2008
I currently have a report where data pulls from a table labeled clients for things such as patient name, address, etc.  However, I would also like to get a count of orders that the client has made.  These orders are stored in a separate table and not counted, but linked by a client id number.  My question is how could i get a count of the number of order rows in a separate table for each client.

Software/Hardware used:
Crystal Reports 2008, SQL Server 2005
ASKED: November 5, 2009  5:36 PM
UPDATED: November 5, 2009  8:16 PM

Answer Wiki:
Lets say you have these 2 tables: CLIENT table with the columns ID, NAME, etc and CLIENT_ORDERS table with ID, ORD_ID, etc You want CLIENT.NAME, count of orders. something like this should work: SELECT C.NAME , COUNT(CO.ORD_ID) FROM CLIENT C , CLIENT_ORDERS CO WHERE C.ID = CO.ID GROUP BY C.NAME;
Last Wiki Answer Submitted:  November 5, 2009  6:45 pm  by  Meandyou   5,205 pts.
All Answer Wiki Contributors:  Meandyou   5,205 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I would prefer this syntax:

SELECT c.name, COUNT(co.ord_id)
FROM client c 
JOIN client_orders co
ON c.id = co.id
GROUP BY c.name; 
 63,535 pts.