-5

I have an excel spreadsheet with:

PatientID, PatientName, DateofService

I want to find out, how many times one patient has visited the doctor and I am trying to import the spreadsheet in MS Access(2010) and use SQL query but I am having errors every time using the COUNT clause. Please help with the SQL query in "ACCESS" to count the each patients'visit(s).

Coding Enthusiast
  • 3,865
  • 1
  • 27
  • 50
Garry
  • 21
  • 4

1 Answers1

1

A query like the following should work for you (Put this in the SQL editor then you can toggle back to the usual query builder view):

SELECT patientNAme, count(DateOFService) as visits FROM <yourTableName> GROUP BY patientName

That will group by PatientName then count the number of times they have visited the doctor. If you want to limit this to a single patient then you can use a WHERE Statement:

SELECT patientNAme, count(DateOFService) as visits FROM <yourTableName> WHERE patientID = <yourpatientID> GROUP BY patientName
JNevill
  • 46,980
  • 4
  • 38
  • 63