110,500
社区成员
发帖
与我相关
我的任务
分享
SELECT
Code,Name,wh,nk,dl,dpp,npp,JP,NJP,NJP2,sum(wh) as wh_total,sum(nk) as nk_total,sum(dl) as dl_total
FROM
(select z.code as Code,h.name as Name,
max(case hokan when 'WH' then zaik else 0 end) as wh,
max(case hokan when 'NK' then zaik else 0 end) as nk,
max(case hokan when 'DL' then zaik else 0 end) as dl,
max(case hokan when 'DPP' then zaik else 0 end) as dpp,
max(case hokan when 'NPP' then zaik else 0 end) as npp,
max(case hokan when 'JP' then zaik else 0 end) as JP,
max(case hokan when 'NJP' then zaik else 0 end) as NJP,
max(case hokan when 'NJP2' then zaik else 0 end) as NJP2
from xzaik z,xhead h where z.code=h.code group by z.code,h.name) as T