How to insert recent record into query result

  • I have a table as:

    Item Value CreatedDate

    A 100 12/01/2009

    A 110 12/02/2009

    A 150 12/05/2009

    How to make a result as below:

    Item Value CreatedDate

    A 100 12/01/2009

    A -100 12/02/2009

    A 110 12/02/2009

    A -110 12/05/2009

    A 150 12/05/2009

    The new record inserted is the same Item with reverse value of most recent record and CreatedDate is the datetime of current record. The last record with max date is remain

    Tks very much

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply