I need the results to look like:
PatientID Doctors Patient1 3 Patient2 2 Patient3 1
The booked table looks like this
Use Group by over a temp table with distinct patient and doctor
select Patient, count(*) from ( select distinct Bookings.PatientID as Patient ,DoctorID as Doctors from Bookings ) as t Group by Patient;