I want to make a query that returns the earliest lab result(which is a row in the table with the earliest date), the serial # and the value for test id1,2 and 3.
Sample data would look like:
This means that a patient could have many rows (because he can take many labs on diff dates) but there is a unique identifier for every lab result on a different date.
Thus for the same patient on the same date could be only one row.
For a patient could be many rows with diff dates.
PAT_SERIAL_NO LAB_DATA_DATE_ID LAB_DATE TEST_ID_1 TEST_ID_2
123345 11223332423123222 17/4/1990 45.3 23.2 123345 33242345634675743 21/7/2001 20.1 11.1 543232 43546547567487686 17/4/1990 45.3
So for this sample data the required output would be:
PAT_SERIAL_NO LAB_DATA_DATE_ID LAB_DATE TEST_ID_1 TEST_ID_2
123345 11223332423123222 17/4/1990 45.3 23.2 543232 43546547567487686
17/4/1990
45.3
I attached the table for further info.