select column1, column2,
count(distinct case when tableB.skirt='blue' then tableB.ID else null end) as numberOfSkirtsInBlue
from tableA
left join tableB
on tableA.ID=tableB.ID
group by column1, column2
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/