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)
 Date Order

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2012-03-23 : 15:43:29
HI All,
I have one table with three column.
i just wanted to know the second last date for each from to
Please suggest

from-to-entered_date

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-23 : 16:06:13
ummm..need a little bit for on the details, don't ya think?

SELECT MAX(dteCol)
FROM yourTable o
WHERE EXISTS (
SELECT * FROM yourTable i
HAVING o.dteCol < MAX(dteCol))

?????




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -