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 2000 Forums
 SQL Server Development (2000)
 SQL Date Comparison Problem

Author  Topic 

ChetShah
Starting Member

37 Posts

Posted - 2007-11-20 : 12:31:09
Hi

I have a temp table which has a row_id and created date:

row_id Created
------- --------------------------
1-3DX08V 2007-10-22 09:14:07.000
1-3DX090 2007-10-22 09:14:11.000

I want to select the latest row Id so i tried

select row_id,max(created)'created'
from #T1
group by row_id

I got the 2 rows above where i'm trying to get the latest row which is 1-3DX090 as it has the latest date.

All T-SQL gurus , please help as my mind has gone blank...

Chet

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-11-20 : 14:08:40
select top 1 * from #t1 order by created desc

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -