• SELECT t1.id,t1.id1

    FROM tbltests t1

    WHERE NOT EXISTS(SELECT * FROM tbltests t2

    WHERE t2.id = t1.id1

    AND t2.id1 = t1.id

    AND t2.id < t2.id1)

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537