Record Count Crystal Reports 2008
20 pts.
0
Q:
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: Nov 5 2009  5:36 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
1840 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
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 Answered: Nov 5 2009  6:45 PM GMT by Meandyou   1840 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Carlosdl   29770 pts.  |   Nov 5 2009  8:16PM GMT

I would prefer this syntax:

SELECT <a href="http://c.name" title="http://c. " target="_blank">c.name</a>, COUNT(co.ord_id)
FROM client c
JOIN client_orders co
ON c.id = co.id
GROUP BY <a href="http://c.name" title="http://c. " target="_blank">c.name</a>; 

 
0