Posted on 2013-12-11
MS SQL Server 2008.
I have three tables joined by a column pat_id.
Table A contains one row per patient (pat_id).
Tables B and C contain many rows for pat_id. They also contain a visitdate column.
What is the general syntax to join these tables so that I have Table A, plus the latest row from Table B and Table C when joining on pat_id?
Use visitdate to obtain the latest record in Tables B and C.
So basically I want for each patient their row from Table A, plus the latest rows from B and C.