Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003

    Unanswered: update end date on based on next start date

    I need to update a table of employee info to enter an end date based on the next start date. Example:

    Employee ID Start End
    1 1/1/2002
    1 1/1/2003
    1 1/1/2005
    2 4/14/2001
    2 1/1/2003
    2 1/1/2006
    2 1/1/2008

    the End data should be one day befor the next start date for that employee. I could write a cursor to do it, but I am trying to get away from cursors and learn something new - any ideas?


  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    what have you tried so far. Without the cursor that is.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Nov 2003
    Below is the query I ended up using; turns out I was over thinking things.

    select a.tkinit,a.tkeffdate, b.tkeffdate - 1

    from timerate a
    left outer join
    timerate b on
    a.tkinit = b.tkinit
    b.tkeffdate =
    ( SELECT min(c.tkeffdate) FROM timerate AS c
    WHERE a.tkinit = c.tkinit AND a.tkeffdate < c.tkeffdate)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts