if there are 2 records with different date
how to write query for --> get record with latest date
Hi,
use Order By clause.
For example,
Select top 1 * from YourTable Order By YourDateFieldName Desc
|||Use something like this:
SELECT TOP 1 *
FROM MyTable
ORDER BY DateField DESC
Regards,
Martin
Here is an example based on the NorthWinds database:
Select TOP 1 *from OrdersOrder by OrderDateDesc|||
Here is another way to do it:
select *
from MyTable
where timestampfield = (select max(timestampfield)
from MyTable)
No comments:
Post a Comment