Subject | How do I get the latest date of a column in a join |
---|---|
Author | Ray Jenkins |
Post date | 2004-06-28T22:45:29Z |
I need to join two tables together and get the latest date in a column in the right table for every record in the left table
My attempt was this sql:
SELECT t.Name, t.CreationDateTime, Max(r.TimeStamp)
FROM
Test t left join Results r on t.TestProgramID = r.TestProgramID
WHERE t.Archived = 1
GROUP BY t.Name
I get an SQL error -104, Invalid expresion in the Aggregate function or the Group By Statement
If I take out the Max function and the Group by statement, I get a list of all Timestamps for each Left side record like I would expect.
Why isn't the Max function working? Is there a different way?
Thanks
Ray
[Non-text portions of this message have been removed]
My attempt was this sql:
SELECT t.Name, t.CreationDateTime, Max(r.TimeStamp)
FROM
Test t left join Results r on t.TestProgramID = r.TestProgramID
WHERE t.Archived = 1
GROUP BY t.Name
I get an SQL error -104, Invalid expresion in the Aggregate function or the Group By Statement
If I take out the Max function and the Group by statement, I get a list of all Timestamps for each Left side record like I would expect.
Why isn't the Max function working? Is there a different way?
Thanks
Ray
[Non-text portions of this message have been removed]