• Oh... one more thing. If there are Null values in any of your comparison columns, then you would have to treat those separately (doing comparisons with Null is a bit tricky). For instance should a Null date be considered lower than another date?

    This can lead to some intricate modifications such as this one...

    select phone , pdate

    into #temptab

    from

    (select p.phone,p.pdate

    from @phonenum p

    join @phonenum p2

    on p.phone = p2.phone or p.phone is null

    GROUP BY p.phone,p.pdate having p.pdate = min(p2.pdate) or p.pdate is null or p.phone is null) t

    So you should think these kinds of situations through before making the final changes.

    Toni