Home Forums SQL Server 7,2000 T-SQL Self join results in duplicate data counts of "paired" data RE: Self join results in duplicate data counts of "paired" data

  • I think you've made it more complicated than necessary. The HAVING option on GROUP BY should do the trick for you without the self-join.select ApplicantID,

    count(*) as CheckCnt,

    RequestDate

    from CreditCheck

    group by ApplicantID, RequestDate

    having count(*) > 1

    This returns:ApplicantID CheckCnt RequestDate

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

    3 4 2009-01-01 00:00:00

    3 2 2009-01-02 00:00:00

    1 2 2009-01-15 00:00:00

    2 2 2009-04-04 00:00:00

    (4 row(s) affected)Edit: If needed, put the date-range desired in a WHERE clause.Select * from Creditcheck

    select ApplicantID,

    count(*) as CheckCnt,

    RequestDate

    from #CreditCheck

    Where RequestDate 1