Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCOUNT

Status
Not open for further replies.

pgh2377

Vendor
Jul 30, 2003
61
US
I have a patient table name "PATIENTS" and contains 3 fields:

CLIENT
PATIENT ID
SALES

Using access, because I don't know SQL, how do I group the Client, counting unique patients and summing sales. The patient may be in there twice for two different sales. I've been trying DCOUNT but having problems. Any suggestions.
 
SELECT CLIENT, Count(*) AS CountOfPatient, Sum(SumOfSales) AS TotalSales
FROM (SELECT CLIENT, [PATIENT ID], Sum(SALES) AS SumOfSales
FROM PATIENTS GROUP BY CLIENT, [PATIENT ID]) AS S

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top