I went to W3Schools and learned the MAX function. They have a "Try it" feature and SELECT ProductID, MAX(Price) FROM Products works. In SSMS SELECT Max(Time) FROM Accounts works but SELECT ID, Max(Time) FROM Accounts results in the error "Column 'Accounts.ID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause." Is this a difference between SQL and TSQL or am I doing something wrong? How do I add columns?


I know I can do a "Select Top 1" and order by date descending but I want to learn how to get the MAX function to work.