I am hoping somebody out there can help me with a query problem I can’t seem to resolve;
I have two tables;
Table1
T1_ID
T1_Serial
Table2
T2_ID
T1_ID –lookup to Table 1
T2_Date
T2_History
Table1 Data might look something like this;
T1_ID T1_Serial
1, ABC1
2, ABC2
3, ABC3
4, ABC4
Table2 Data might look like this;
T2_ID, T1_ID, T2_Date, T2_History
1, 1, 05/05/15, “Some History1”
2, 1, 05/17/15, “Some History2”
3, 2, 05/09/15, “Some History3”
4, 2, 05/21/15, “Some History4”
5, 3, 05/12/15, “Some History5”
I would like to set up a query to give me the record containing Max(Date) of table History for each record in table Units
Table1.T1_Serial , Max(T2_Date), T2_History;
For this example;
ABC1 05/17/15 “Some History2”
ABC2 05/21/15 “Some History4”
ABC3 05/12/15 “Some History5”
I have constructed the SQL to give me the T1_Serial and Max(Date), which is working correctly;
SELECT Table2.T1_ID, Max(Table2.T2_Date) AS MaxDate
FROM Table2
GROUP BY Table2.T1_ID;
But when I try adding the T2_History to the query I end up getting all the other history besides the Max(Date).
Hope someone can lead me on the right path. Thanks!