Reputation: 11
I have multiple records all with the same user_id
and each with its unique TIMESTAMP
.
I need to return the correct data for a user_id
based on the latest date - MAX(date)
.
My query returns the last date but the incorrect data (ie Data associated with a previous record-set):
SELECT user_id, doc_docpath_00, max(doc_uploadtimestamp) FROM doc
WHERE user_id = '90';
Could you help me understanding how to correct my query?
Upvotes: 1
Views: 245
Reputation: 76
I don't think it can work that way.
I believe you should try something like:
select user_id, doc_docpath_00
from doc
where user_id = '90' and doc_uploadtimestamp = (
select max(doc_uploadtimestamp)
from doc where user_id = '90');
Upvotes: 2