记录以防止忘记:
select a.*,case when rn=1 then globaldebit end je from(
select ct_pu.vbillcode,ap_payitem.contractno,ct_pu.ctname,
ap_payitem.globaldebit,
row_number()over(partition by ct_pu.vbillcode order by ct_pu.vbillcode) rn
from ct_pu
inner join ct_pu_b
on ct_pu.pk_ct_pu=ct_pu_b.pk_ct_pu
left join ap_payitem
on ap_payitem.contractno=ct_pu.vbillcode
where
nvl(ct_pu.dr,0)=0
and nvl(ap_payitem.dr,0)=0
and ap_payitem.contractno is not null
) a