• nitin_456 (1/5/2013)


    Is there any other way to achieve this without CTE.

    Not sure why you don't want the cte version, but this works (though untested):

    SELECT A.House_acc ,

    A.AccountId ,

    A.repcode

    FROM

    (

    SELECT House_acc

    FROM yourtable

    GROUP BY House_acc

    HAVING (COUNT(DISTINCT repcode) > 1)

    ) dt

    INNER JOIN yourtable AS A

    ON dt.House_acc = A.House_acc;