I'm trying to simply select the value which has the latest timestamp, but for some reason I'm having some sort of brain freeze.
The code below is selecting all the records:
SELECT S.idindicator, S.val ,[Time] = MAX(CAST(S.valTimestamp as date)), S.valTimestamp
FROM Status as S
WHERE S.INVALID = 0
AND S.id = 16888
GROUP by S.idindicator, S.val, S.valTimestamp
ORDER BY S.valTimestamp DESC
How do I simply just select the val
which has the latest date, which is 75.00?
Note: I have done it using a correlated subquery, however, it turns it into an expensive query.