Link to home
Create AccountLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

top 1 row where datetime is the earliest

top 1 row where datetime is the earliest
ASKER CERTIFIED SOLUTION
Avatar of pateljitu
pateljitu
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer

something like this

declare dtTarget datetime
set dtTartet = (select min(dtField)from TableA)
select top 1 * from TableA where dtField = dtTarget


Pateljitu's is better.  Wasn't thinking.
pateljitu,

earliest != latest ;)

select top 1 * from sometable
order by datetimecolumn ASC
Avatar of rgb192

ASKER

thanks