Hi,
I have two tables, one with sample dates and corresponding temperature values, and a second table with height values and the dates when these height values were taken:
Table_1_Samples Sample_Date Temperature 3/3/13 20 3/6/13 18 3/15/13 21 3/20/13 20 4/1/13 16 4/7/13 20 4/18/13 17
Table_2_Heights Height_Date Height 3/1/13 15 3/7/13 20 3/19/13 13 4/15/13 17
I need to know, for each sample date and temperature, when was the last height measurement taken and what was that height. The output should look something like this:
So, for the first sample date (3/3/13), the last height date should be 3/1/13 and the height should be "15", for the second to last sample date (4/7/13), the last height date should be "3/19/13" and the corresponding height should be "13".
Sample_Date Temperature Last_Height_Date Height 3/3/13 20 ? ? 3/6/13 18 ? ? 3/15/13 21 ? ? 3/20/13 20 ? ? 4/1/13 16 ? ? 4/7/13 20 ? ? 4/18/13 17 ? ?
What is the best way to query my tables to generate these two new columns with the right information? All and any help is greatly appreciated. I've been trying to solve this on my own, and I can't figure it out.
Thanks!!