I got a single table and it contain 4 fields
Id|Hospital| Doctor|patient 1 A D1 P11 2 B D6 P61 3 A D2 P21 4 A D1 P12 5 B D7 P71 6 B D6 P62 7 B D6 P63
Doctors are unique to the Hospital. They don't work in other hospitals. Patients are unique to the doctor they don't visit any other doctor. Each hospital is having multiple Doctors.
If you observe there are multiple patients for each doctor.
Now the question is: How can I get "only one patient" related to the each doctor. It can be any patient from the record.
I am looking forward to see some thing like this
Hospital Doctor Patient A D1 P11 A D2 P21 B D6 P61 B D7 P71
I got the answer like select Hospital,doctor, max(patient) from table GROUP BY Hospital,Doctor ORDER BY Hospital,Doctor;
How to get the id also which is unique from the above table like.
id Hospital Doctor Patient 1 A D1 P11 3 A D2 P21 2 B D6 P61 5 B D7 P71
I am very sorry to repost this question.