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!

UNIQUE COUNT

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.
 
Try
Code:
Select T.Client, 
 
       (Select Count(*) From 
           (Select DISTINCT [Patient ID] From tbl As X
            Where X.Client = T.Client) As Dummy ) As [PatientCount],

        SUM ( T.Sales ) As [TotalSales]

From tbl As T

Group By T.Client
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top