How to get latest Records based on Date column

  • Hi,

    I have a table like below.

    Item_ID Item_number Date _Created

    1 101 NULL

    2 102 NULL

    3 103 NULL

    4 101 2012-08-21

    5 102 2012-08-22

    6 101 2012-09-05

    7 103 2012-09-05

    8 104 2012-10-12

    9 104 2012-11-14

    Now i need to copy all latest items into othet table based on Date_Created.

    Required records:

    Item_ID Item_number Date _Created

    6 101 2012-09-05

    5 102 2012-08-22

    7 103 2012-09-05

    9 104 2012-11-14

    Can anyone please suggest on this..

    Thanks in Advance!

    Kumar

  • Can you write a SELECT which returns the rows you want to copy? If not, what's the date range which identifies rows to copy? This is trivial, is it homework?

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • This does kinda look like homework.

    Look up Row_Number in BOL. It should go some ways to resolving your problem.

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

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