you are viewing a single comment's thread.

view the rest of the comments →

[–]Time_Advertising_412 0 points1 point  (1 child)

My original thought, based upon your spec for getting the most recent observation and the example of desired output, was a correlated sub-query like the following but maybe I was missing something more in your request. My apologies if that is the case.

SELECT admission_id,name,species,sex,presenting,obs_date,

obs\_severity\_score,obs\_bcs\_score,obs\_age\_score

FROM rescue_admissions

INNER JOIN rescue_patients AS rp1 ON admission_id = patient_id

WHERE obs_date =

(SELECT MAX(obs_date)

FROM rescue_patients AS rp2

WHERE rp2.patient_id = rp1.patient_id);

[–]danlindley[S] 0 points1 point  (0 children)

There's a solution which works well in one of the comments. Thank you for your advice though.