Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Get record that have greater date

Author  Topic 

dungla
Starting Member

2 Posts

Posted - 2008-09-10 : 00:43:59
Hi there,

I've 2 records:
ID Date Value1 Value2
584 2008-07-01 00:00:00.000 4000 0
584 2008-08-01 00:00:00.000 5000 0

How can I select the record which have greater date (2008-08-01)?

LAD

hey001us
Posting Yak Master

185 Posts

Posted - 2008-09-10 : 00:48:59
SELECT * FROM Table WHERE Date in (SELECT MAX(Date) from Table)

hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-10 : 00:52:55
[code]select top 1 *
from yourtable
order by Date desc[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-10 : 03:44:49
select t.* from
(
select *,row_number() over (order by date desc) as sno from yourtable
) as t
where sno=1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -