I have a table with 5 columns...
* RowID (guid)
* [Date] (datetime)
* AssetID (guid)
* Value1 (int/varchar...)
* Value2 (int/varchar...)
I need to find the most recent values of Value1 and Value2 for all AssetID's.
This query
Code: Select all
SELECT MAX([Date]), AssetID FROM MyTable GROUP BY AssetID
Code: Select all
SELECT MAX([Date]), AssetID, Value1, Value2 FROM MyTable GROUP BY AssetID
Code: Select all
Column 'whatever' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.