I have a database with patients, doctors, cabinets and visits.
Patients (id_pac, FirstName, LastName)
Doctors (id_med, FirstName, LastName, Speciality)
Cabinets (id_cab, Name)
Vizits (id_viz, Date_viz, Medic_id,Patient_id, Cabinet_id)
One doctor can make visits on different patients, on different cabinets, on different dates.
I need to find out (with a subquery or with a join ? , but NOT with intermediary tables or views), in one report :
- one column with the doctor’s complete name : CONCAT(FirstName,’ ‘,LastName) (DISTINCT),
- one column with the cabinet name in which the doctor was having the biggest number of visits
and
3.one column with the number of visits for this cabinet.
I have tried to figure out how can i get this information, but all what I can have is
the list of doctors with every cabinets in which he was having visits, with the total number of visits / cabinet :((
1 Answer