1 Select * From
a,b b1
where a.cutomerid='3' and b.type='3,7,9,12'
and id in (select top 1 id from b where type=b1.type)
2 Select *,(select count(*) from T where type = t1.type) TOT From
a,b b1
where a.cutomerid='3' and b.type='3,7,9,12'
and id in (select top 1 id from b where type=b1.type)