title: Join and count in SQL Server
body: <p>I have two tables; let's call them TableA and TableB. Each element of TableB is associated with an element of TableA in a many-to-one relationship. Some elements of TableA may have no corresponding element in TableB.</p>
  
  <p>I need to select every element in TableA, along with a column that will, for each row in the result set, contain the number of elements in TableB that are associated with that row in TableA, and that have a certain property.</p>
  
  <p>Using MS SQL Server 2008 (Needs to also work in SQL Server 2005).</p>