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)
 Display 2nd latest date

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2009-05-02 : 07:55:04
Hi,

My table as follow,
TrnxID | In | Dte
--------------------------------------------
1 | UM | 4/20/2008 3:36:11 PM
2 | UM | 4/20/2008 7:45:56 PM
3 | UM | 4/21/2008 2:33:24 PM
4 | UM | 4/21/2008 10:02:14 PM

How to display 2nd latest date from above table?

My expected result should be
3 | UM | 4/21/2008 2:33:24 PM

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-02 : 08:18:35
Just an idea...

select top 1 * from
(select top 2 * from table order by Dte DESC) t
order by Dte ASC



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-02 : 08:20:11
This will work only if no Dte is stored twice...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2009-05-04 : 07:10:22
tq very much
Go to Top of Page
   

- Advertisement -