• Instead of using an IN clause, use another JOIN to retrieve that data. You would have to build a dynamic statement to perform a count before you tried to JOIN, requiring two different queries. That's an option, but not always a good one. Also, to help with performance, capturing and post the actual execution plan makes it easier to understand how your structures and query are working within the optimizer.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning