How get earliest timestamp?

M

mscertified

I have a table with a date/time column.
I need to retrieve the earliest timestamp record.
I'm currently using SELECT MIN(timestamp), is this correct?

Thanks.
 
K

Klatuu

Yes.
But, are you filtering the query so it returns only one record?
If not, then you would need SELECT TOP 1 MIN(timestamp)
But then, I am thinking if you want to return only one value, why not use a
DMin function instead?
 
M

mscertified

Good point. I had ignored the possibility of duplicate timestamps, but I
suppose it could happen!
 
P

Paul Shapiro

Not an issue. If your query is ONLY referencing aggregate functions, then
only a single row will be returned. Even if there are duplicate data values,
there's still only a single value for the min().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top