January 17, 2010 at 8:30 pm
Hello to all experts
I don't know whether the following can be done or not in T-SQL without the use of front-end programming language
I have a table which has the following rows:
Emp_ID Position_ID Start_Date
1 0200 01-01-2009
1 0300 01-04-2009
1 0400 01-08-2009
2 0200 01-01-2009
The above rows are in a staging tables. I am building my base tables data out of the staging tables
I want the following output.
Emp_ID Position_ID Start_Date End_Date
1 0200 01-01-2009 31-03-2009
1 0300 01-04-2009 31-07-2009
1 0400 01-08-2009 NULL
2 0200 01-01-2009 NULL
This means that the End_Date should be a day less than the next position starts for an employee ID.
Could anyone please throw some light on this.
Thank you.
January 17, 2010 at 9:40 pm
A self join with a ROW_NUMBER reference would probably do it. If you want a coded answer, please see the first link in my signature line below.
--Jeff Moden
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply