• John Mitchell-245523 (8/22/2013)


    Here you go. Obviously it doesn't return any rows for your sample data, but if it did, you could join back to A if you need the student name.

    John

    SELECT

    B.StudentID

    FROM

    B

    JOIN

    TblData d ON B.ClassID = d.ClassID AND B.SectionID = d.SectionID

    GROUP BY

    b.StudentID

    HAVING

    COUNT(*) = (SELECT COUNT(*) FROM TblData)

    Can you please tell me why we need this -

    HAVING

    COUNT(*) = (SELECT COUNT(*) FROM TblData)

    its not clear to me..

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/