Removing Duplicates with condition - Help

  • I have following data

    ACNO,Date,Nodename

    1,2001-06-15,A1

    2,2002-02-07,A2

    3,2001-01-22,A3

    1,2003-06-22,A1,

    4,2007-12-22,A4

    1,2008-01-23,A1

    5,2000-11-23,A1

    What result i am looking for is

    ACNO,Date,Nodename

    5,2000-11-23,A1

    4,2007-12-22,A4

    3,2001-01-22,A3

    2,2002-02-07,A2

    1,2008-01-23,A1(latest row on NodeName)

    Please help on T-SQL.

    Thanks

  • SELECT Acno, [Date], NodeName

    FROM

    (

    &nbsp&nbsp&nbsp&nbspSELECT ROW_NUMBER() OVER (PARTITION BY AcNo ORDER BY [Date] DESC) AS RowId

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp,Acno, [Date], NodeName

    &nbsp&nbsp&nbsp&nbspFROM YourTable

    ) D

    WHERE RowId = 1

    ORDER BY AcNo DESC

  • Yes, Thank you very much for the help.

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

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