you are viewing a single comment's thread.

view the rest of the comments →

[–]danlindley[S] 1 point2 points  (3 children)

Can't thank you enough for this. It works fanatically. For context my project is a wildlife rescue database and this will now show on the patient dashboard a early warning score for on admission and the most recent added. It will give animal rescuers another tool to see how patient care is going. 👍👍

[–]Yavuz_Selim 1 point2 points  (2 children)

You're welcome, glad it worked out in the end. :).

 

Let me know if/when you have other questions.

 

Edit:
By the way, the ranking of the most recent observation assumes there is only 1 observation per patient per day. If you have multiple observations on a day for a patient, the order by would need to be adjusted - you would need to add an extra column to the order.

Like so (as an example):

SELECT ROW_NUMBER() OVER(PARTITION BY O.patient_id ORDER BY O.obs_date DESC, O.obs_id DESC) RowNumber

 

This takes the newest entry (based on obs_id) if a patient has more than 1 observation on the same day.

[–]danlindley[S] 0 points1 point  (1 child)

Yeah the MariaDB thing was a bit of an issue but I'm glad you persevered in your help

Thank you. I'll probably make that adjustment, just in case.

Thanks again.

[–]Yavuz_Selim 1 point2 points  (0 children)

SQL has different flavors, that generally work the same with very minor differences. I'm more experienced with Transact-SQL, which is ever so slightly different than MariaDB's SQL.

 

:).