我正在尝试join
基于primary key
地址编号 1 的表格。但是,下面的问题会为同一地址编号创建重复记录。003 78057911 (wpphtp !=F) 和 003 78057922 (wpphtp = F) 是相同的字段database
,但是我想在不同的列上提取它。我该怎么做?
select ABAN8,'CREATE',ABALPH, '','', '','','','','','', EAEMAL,'',
CASE
WHEN wpphtp != 'F'
THEN WPAR1
else ' '
END AS prefix ,'', CASE
WHEN wpphtp != 'F'
THEN WPph1
else ' '
END AS phone, '',CASE
WHEN wpphtp = 'F'
THEN wpar1
else ' '
END AS prefixfax,' ',CASE
WHEN wpphtp = 'F'
THEN wpph1
else ' '
END AS fax from PRODDTA.F0111
join PRODDTA.F01151 on proddta.f0111.wwan8 = PRODDTA.F01151.EAAN8
join PRODDTA.F0115 JOIN PRODDTA.F0101 ON PRODDTA.F0115.wpAN8 = PRODDTA.F0101.ABAN8
ON PRODDTA.F0115.wpAN8 = PRODDTA.F0111.wwAN8 where wwidln < 1
order by wwan8
结果:
1 | CREATE | E-GLOBAL INNOVATIVE SDN BHD | kinki@hostpro2u.com | 003 | 78057911
1 | CREATE | E-GLOBAL INNOVATIVE SDN BHD | billing@hostpro2u.com | 003 | 78057911
1 | CREATE | E-GLOBAL INNOVATIVE SDN BHD | kinki@hostpro2u.com | 003 | 78057922
1 | CREATE | E-GLOBAL INNOVATIVE SDN BHD | billing@hostpro2u.com | 003 | 78057922
预期结果:
1 CREATE | E-GLOBAL INNOVATIVE SDN BHD | kinki@hostpro2u.com | 003 | 78057911 | 003 | 78057922
1 CREATE | E-GLOBAL INNOVATIVE SDN BHD | billing@hostpro2u.com | 003 | 78057911 | 003 | 78057922