Reply to Re: Finding the most recient datetime

Your name:

Reply:


Posted by Simon Hayes on 09/26/05 20:22

JohnnyRuin wrote:
> Hi,
>
> My table has int Field1 and DateTime dtModificationTime. I maintain a
> history of changes to the table by inserting a new record with a new
> dtModificationTime. I need to be able to find the last inserted
> record. It's easy to do Select * from table where field1=x ORDER BY
> dtModificationTime. That works, but it hits all the records that
> match the field. I need to come back with an exact hit. Can someone
> point me in the right direction?
>
> Thanks.
>
See "Limiting Result Sets Using TOP and PERCENT", SET ROWCOUNT and
SELECT in Books Online:

select top 1 Field1, dtModificationTime
from dbo.MyTable
order by dtModificationTime desc

You should probably also consider what happens when you have multiple
rows with the same value in dtModificationTime.

Simon

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация