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.
Author |
Topic |
ninel
Posting Yak Master
141 Posts |
Posted - 2010-05-15 : 01:08:29
|
I have a table that stores dates of records that need to be reprocessed. Normally I would use MIN function to pick up the earliest date I need processed. Lately i've been finding at least one date is out of the norm. So instead of picking up the min I'd like to pick up the next in line.For example, the first date is 20090104 (which min would give me), then 20100403 then 20100404,20100405 but i want to pick up the next one. This is a night time process and I won't know which dates are in the table so I can't hardcode. I'm only checking if the 1st date returned by the min is greater than 30 days from current day. Is there any way of doing this?Thanks,Ninel |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-15 : 03:44:30
|
sorry not clear. can you post some data sample from table and then explain what you want?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2010-05-23 : 12:09:44
|
As Visakh said, your questions is not clear.From my guess,Use ROW_NUMBER() function and get the date which is second sequence. |
 |
|
naveengopinathasari
Yak Posting Veteran
60 Posts |
Posted - 2010-05-25 : 05:37:10
|
Hi,Here is the query to get the last But the other records, if i have understood your requirement.Create a table Test with PurchaseDate (DateTime)----------------------------------------------------------------------------------Select * From dbo.Test WherePurchaseDate > (Select DATEADD( DD, 1,Min(PurchaseDate)) From dbo.Test)-----------------------------------------------------------------------------------Let me know if its not feasible for your requirement.Lets unLearn |
 |
|
|
|
|