Hello,
I am trying to run this query:
Code:
SELECT LoadTestID, SerialNumberID, Max(DateofTest) AS Last_Load_Test
FROM TBL_Load_Tests
GROUP BY LoadTestID, SerialNumberID, LoadTestType
HAVING (((LoadTestType)=2));
I have a table (tbl_Load_Tests) which tracks Load Tests on equipment (SerialNumberID). Multiple Load Tests are performed annually on the same SerialNumberID. I want to see the most recent Load Test Date for each SerialNumberID and the LoadTestID (Primary Key for tbl_Load_Tests) created for that Load Test.
If I run this query without looking for the LoadTestID, it works perfect.
Code:
SELECT SerialNumberID, Max(DateofTest) AS Last_Load_Test
FROM TBL_Load_Tests
GROUP BY SerialNumberID, LoadTestType
HAVING (((LoadTestType)=2));
But when I add in LoadTestID (first code), it returns EVERY Load Test performed and not just the Max Date of each SerialNumberiD.
What am I doing wrong?
Thank you for your help!