I have a query that filter records with recent time stamp. The query filter recent records but it's filtering other records also. For example: it should diplay recent record from 2000-2016, it filter recent record and also it's filtering records from 2012 to 2015 like not displaying these records although these should be display with the recent timestamp.Below is the sql:
SELECT t.ID, t.Country, t.Product, t.Years, t.Values, t.Show, t.Current, t.Source, t.Notes, t.Entered_By, t.Timestamp, t.Sector, t.PType, t.Flow, t.Unit, t.DataType
FROM qryUnion AS t INNER JOIN (SELECT [qryUnion].Country, [qryUnion].Product, [qryUnion].Years, [qryUnion].Flow, [qryUnion].DataType, MAX([qryUnion].Timestamp) AS MaxofTimestamp FROM qryUnion GROUP BY [qryUnion].Country, [qryUnion].Product, [qryUnion].Years,[qryUnion].Flow, [qryUnion].DataType) AS q ON (t.Timestamp = q.MaxofTimestamp) AND (t.Flow = q.Flow) AND (t.Years = q.Years) AND (t.Product = q.Product) AND (t.Country = q.Country) AND (t.DataType = q.DataType);
i try to figure out the error, i guess it's for timestamp which i am not able to figure out how.