首先要确定你重复的记录最多有多少条,我这里假设最多有两条重复customerid的记录
select
customerId,
case when count(*)>=2 then 2 else max(type) end as type,
sum(orderNum) as orderNum,
SUBSTRING_INDEX(group_concat(shkd),',',1) as shkd,
SUBSTRING_INDEX(group_concat(srmb),',',1) as srmb,
SUBSTRING_INDEX(group_concat(ahkd),',',1) as ahkd,
SUBSTRING_INDEX(group_concat(armb),',',1) as armb,
SUBSTRING_INDEX(group_concat(shkd),',',-1) as shkd2,
SUBSTRING_INDEX(group_concat(srmb),',',-1) as srmb2,
SUBSTRING_INDEX(group_concat(ahkd),',',-1) as ahkd2,
SUBSTRING_INDEX(group_concat(armb),',',-1) as armb2
from tableName group by customerId