I have a group of records with the same data except the timestamp (yes, not my design)
Example:
record_id, user, tmstmp
1, myself, 2006-11-15 09:56:14.325882-05
1, myself, 2006-11-15 09:56:19.051823-05
1, myself, 2006-11-15 11:23:30.581366-05
etc...
Now I would like to UPDATE the record with the last timestamp. Here is what I'm trying so far with no luck:
UPDATE tbl
SET user = 'TESTING'
WHERE record_id = 1
ORDER BY tmstmp DESC
LIMIT 1
ORDER BY throws a syntax error.
I think this should be an AND condition, but not seeing how to do it. Any thoughts?
PostgreSQL is my db.
source
share