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 |
|
grandfso
Starting Member
2 Posts |
Posted - 2011-03-10 : 07:32:47
|
Hi,I have a table like this one. What I need to do select the SCHEDULED DATE which is 10th from the end for each Inv#... Have no clue how to do this. I appreciate this is easy for more experienced SQL professionals however for me as a newbie this is an obstacle I am unable overcome at the moment. Any help appreciated.Inv# SID SCHEDULED DATE ACTUAL DATE10000 1 2004-11-07 00:00:00 2004-11-22 00:00:0010000 2 2004-12-07 00:00:00 2004-12-10 00:00:0010000 3 2005-01-07 00:00:00 2005-01-12 00:00:0010000 4 2005-02-07 00:00:00 2005-02-11 00:00:0010000 5 2005-03-07 00:00:00 2005-03-16 00:00:0010000 6 2005-04-07 00:00:00 2005-04-15 00:00:0010000 7 2005-05-07 00:00:00 2005-05-17 00:00:0010000 8 2005-06-07 00:00:00 2005-07-25 00:00:0010000 9 2005-07-07 00:00:00 2005-08-17 00:00:0010000 10 2005-08-07 00:00:00 2005-08-17 00:00:0010000 11 2005-09-07 00:00:00 2005-09-12 00:00:0010000 12 2005-10-07 00:00:00 2005-11-16 00:00:0010000 13 2005-11-07 00:00:00 2005-11-16 00:00:0010000 14 2005-12-07 00:00:00 2006-02-28 00:00:0010000 15 2006-01-07 00:00:00 2006-03-31 00:00:0010000 16 2006-02-07 00:00:00 2006-03-31 00:00:0010000 17 2006-03-07 00:00:00 2006-05-02 00:00:0010000 18 2006-04-07 00:00:00 2006-06-30 00:00:0010000 19 2006-05-07 00:00:00 2006-06-30 00:00:0010000 20 2006-06-07 00:00:00 2006-07-26 00:00:0010000 21 2006-07-07 00:00:00 2006-08-28 00:00:0010000 22 2006-08-07 00:00:00 2006-08-28 00:00:0010000 23 2006-09-07 00:00:00 2006-10-05 00:00:0010000 24 2006-10-07 00:00:00 2006-10-05 00:00:0010000 25 2006-11-07 00:00:00 2006-10-25 00:00:0010000 26 2006-12-07 00:00:00 2006-12-07 00:00:0010000 27 2007-01-07 00:00:00 2006-12-07 00:00:0010000 28 2007-02-07 00:00:00 2006-12-07 00:00:0010000 29 2007-03-07 00:00:00 2007-01-25 00:00:0010000 30 2007-04-07 00:00:00 2007-01-25 00:00:0010000 31 2007-05-07 00:00:00 2007-02-28 00:00:0010000 32 2007-06-07 00:00:00 2007-02-28 00:00:0010000 33 2007-07-07 00:00:00 2007-03-20 00:00:0010000 34 2007-08-07 00:00:00 2007-03-20 00:00:0010000 35 2007-09-07 00:00:00 2007-03-20 00:00:0010000 36 2007-10-07 00:00:00 2008-09-16 00:00:0010001 1 2004-11-07 00:00:00 2004-11-15 00:00:0010001 2 2004-12-07 00:00:00 2004-12-08 00:00:0010001 3 2005-01-07 00:00:00 2005-01-18 00:00:0010001 4 2005-02-07 00:00:00 2005-02-10 00:00:0010001 5 2005-03-07 00:00:00 2005-03-18 00:00:0010001 6 2005-04-07 00:00:00 2005-04-13 00:00:0010001 7 2005-05-07 00:00:00 2005-05-16 00:00:0010001 8 2005-06-07 00:00:00 2005-06-10 00:00:0010001 9 2005-07-07 00:00:00 2005-07-08 00:00:0010001 10 2005-08-07 00:00:00 2005-09-14 00:00:0010001 11 2005-09-07 00:00:00 2005-10-28 00:00:0010001 12 2005-10-07 00:00:00 2005-12-13 00:00:0010001 13 2005-11-07 00:00:00 2006-10-23 00:00:0010001 14 2005-12-07 00:00:00 2007-02-21 00:00:0010001 15 2006-01-07 00:00:00 2007-10-23 00:00:0010001 16 2006-02-07 00:00:00 2008-01-22 00:00:0010001 17 2006-03-07 00:00:00 2008-01-22 00:00:0010001 18 2006-04-07 00:00:00 2008-02-22 00:00:0010001 19 2006-05-07 00:00:00 2008-03-25 00:00:0010001 20 2006-06-07 00:00:00 2008-03-25 00:00:0010001 21 2006-07-07 00:00:00 2008-06-23 00:00:0010001 22 2006-08-07 00:00:00 2008-08-22 00:00:0010001 23 2006-09-07 00:00:00 2008-10-21 00:00:0010001 24 2006-10-07 00:00:00 2008-12-22 00:00:0010001 25 2006-11-07 00:00:00 2009-07-21 00:00:0010001 26 2006-12-07 00:00:00 2009-09-22 00:00:0010001 27 2007-01-07 00:00:00 2009-10-22 00:00:0010001 28 2007-02-07 00:00:00 2009-11-24 00:00:0010001 29 2007-03-07 00:00:00 2010-01-25 00:00:0010001 30 2007-04-07 00:00:00 2010-03-23 00:00:0010001 31 2007-05-07 00:00:00 2010-06-24 00:00:0010001 32 2007-06-07 00:00:00 2010-08-24 00:00:0010001 33 2007-07-07 00:00:00 2011-02-23 00:00:0010001 34 2007-08-07 00:00:00 NULL10001 35 2007-09-07 00:00:00 NULL10001 36 2007-10-07 00:00:00 NULL10002 1 2004-11-01 00:00:00 2004-11-08 00:00:0010002 2 2004-12-01 00:00:00 2004-12-01 00:00:0010002 3 2005-01-01 00:00:00 2004-12-31 00:00:0010002 4 2005-02-01 00:00:00 2005-01-28 00:00:0010002 5 2005-03-01 00:00:00 2005-03-03 00:00:0010002 6 2005-04-01 00:00:00 2005-03-29 00:00:0010002 7 2005-05-01 00:00:00 2005-04-28 00:00:0010002 8 2005-06-01 00:00:00 2005-06-01 00:00:0010002 9 2005-07-01 00:00:00 2005-07-09 00:00:0010002 10 2005-08-01 00:00:00 2005-08-05 00:00:0010002 11 2005-09-01 00:00:00 2005-10-26 00:00:0010002 12 2005-10-01 00:00:00 2005-10-26 00:00:0010002 13 2005-11-01 00:00:00 2005-10-26 00:00:0010002 14 2005-12-01 00:00:00 2006-09-28 00:00:0010002 15 2006-01-01 00:00:00 2007-06-21 00:00:0010002 16 2006-02-01 00:00:00 2007-07-25 00:00:0010002 17 2006-03-01 00:00:00 2008-03-27 00:00:0010002 18 2006-04-01 00:00:00 2009-03-23 00:00:0010002 19 2006-05-01 00:00:00 NULL10002 20 2006-06-01 00:00:00 NULL10002 21 2006-07-01 00:00:00 NULL10002 22 2006-08-01 00:00:00 NULL10002 23 2006-09-01 00:00:00 NULL10002 24 2006-10-01 00:00:00 NULL10002 25 2006-11-01 00:00:00 NULL10002 26 2006-12-01 00:00:00 NULL10002 27 2007-01-01 00:00:00 NULL10002 28 2007-02-01 00:00:00 NULL |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-03-10 : 07:47:46
|
if you are using SQL 2005/2008, use the row_number() function KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
grandfso
Starting Member
2 Posts |
Posted - 2011-03-11 : 08:24:48
|
| Thanks for replies, This resultset was joined to another resultset so In the end I used Joins to get it done.thanks and regards, Grand |
 |
|
|
|
|
|