Trying to get the first record for each member id in my sorted list.
SELECT [member_id]
,[physician_id]
,[most_recent_date]
,[num_visits]
FROM table1
order by [member_id] asc, num_visits desc, [most_recent_date] desc
The table contains a list of members, the physician(s) they seen, date of the most recent visit with that particular physician, and how many times they saw that physician.
Goal is to determine which physician is responsible for that patient based on the following logic. 1) Which ever physician the patient visited the most is responsible, if tied then 2) which ever physician the patient most recently visited is responsible.
I have my list sorted, such that the top entry for each member id would be the physician responsible, how do I carve that out so I only have a single entry for each member with my physician information (physician_id, most recent date, num_visits)?
SELECT [member_id]
,[physician_id]
,[most_recent_date]
,[num_visits]
FROM table1
order by [member_id] asc, num_visits desc, [most_recent_date] desc
The table contains a list of members, the physician(s) they seen, date of the most recent visit with that particular physician, and how many times they saw that physician.
Goal is to determine which physician is responsible for that patient based on the following logic. 1) Which ever physician the patient visited the most is responsible, if tied then 2) which ever physician the patient most recently visited is responsible.
I have my list sorted, such that the top entry for each member id would be the physician responsible, how do I carve that out so I only have a single entry for each member with my physician information (physician_id, most recent date, num_visits)?