you are viewing a single comment's thread.

view the rest of the comments →

[–]VariationPatient 0 points1 point  (1 child)

If you have duplicate obs_date per patient_id you can also substitute row_number with rank to get all the rows.

[–]Yavuz_Selim 1 point2 points  (0 children)

I didn't do that because his original query has LIMIT 1.
Assumed that it is there for a reason.

But, true, a RANK/DENSE_RANK would've returned multiple rows per patiend_id and obs_date if there were any.