select serialno, companyno, customer, sourcecode, itemclass, group, subgroup,
case when employeecd = 'A' then 1 else 0 end,
case when employeecd = 'B' then 1 else 0 end,
case when employeecd = 'C' then 1 else 0 end,
from sourcemarket
where serailno in select min(serialno)
from sourcemarket
join customer
on sourcemarket.sourcecode = customer.companyno
and sourcemarket.customer = customer.customer
and sourcemarket.sourcecode = customer.sourcecode
group by Group by companyno,customer,sourcecode,itemclass,group,subgroup
这里我们为第一个客户和EMP值(A,B,C,... I,X)构建文件,用于最少组合CSNR / SRCD / ITCL / GRP / SGRP