remove duplicate records

  • We have a table with School range Program defined in each school and grade level.

    At beginning we use RangCd like 9-12, K-5, but later for some of them we closed the program and open the program with RangeCd separately in each grade, like 09, 10, 11, 12.

    So now in application code side, because of the duplicate, it caused some issue.

    They want to remove those duplicated records that in a range like 9-12, and keep others with separate grade levels.

    The hard part for me is not knowing how to compare the RangCd column, because some of it are range, some are only one grade level.

    I attached the table, and some sample data.

    The final purpose is to delete those records with rangeCode like %-% that are already exist in the form of each grade level.

    .

  • Not sure about others, but when I viewed your attachment, it is all run together. I'm not about to run this code on my computers when I can't even tell what is what.

  • Sorry, for some reason when I save from .sql to .txt, it changes the format.

    i will try to attach it again.

  • I will reload them

  • Reload the script

  • Here is something that could help you write a query to dedupe your data

    http://jasonbrimhall.info/2011/03/21/dedupe-data-cte/

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • For my case, the hard part is I would like to compare the rangeCd that is a range, and separate grade level and make them not duplicate

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

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