Hi, This query dose not answer because RegNo in Table_B in Id 4 dose not equal with RegNo with Table_A, But if it's correct this is answer select a.RegNo,a.Name,count(a.Class),b.LastUpdated from Table_A as a left join Table_B as b on a.RegNo=b.RegNo where (b.Id between 3 and 4 ) or (a.RegNo Not In('16RTY')and a.RegNo In('14DFG','15FHG')) group by a.RegNo,a.Name,b.LastUpdated