Having to return the count of a unique Bill of Materials (BOM) where each BOM have multiple positions, I dd something like this:
select t_item, t_pono, count(distinct ltrim(rtrim(t_item)) + cast(t_pono as varchar(3))) as [BOM Pono Count]
from BOMMaster
where t_pono = 1
group by t_item, t_pono
Given t_pono is a smallint datatype and t_item is a varchar(16) datatype