• Lynne's solution works if we assume that the retained ID is always the maximum.

    But tthe solution doesn't work with the following record set:

    drop table dbo.testing

    create table dbo.testing (retained int, dropped int)

    insert into dbo.testing (retained, dropped)

    select 767884, 157441 union all

    select 1046261, 157441 union all

    select 6699, 157441 union all

    select 157441, 73635 union all

    select 767884, 73635 union all

    select 1046261, 73635 union all

    select 6699, 73635 union all

    select 1046261, 767884 union all

    select 6699, 767884 union all

    select 6699, 1046261

    I will keep trying to see if I can come up with a solution but if anyone else can think of something then that'd be great!

    Thanks in advance.

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn