|
|

楼主 |
发表于 2009/3/26 10:32:01
|
显示全部楼层
报表脚本:
select * from
(
select a.status,A.Projectid,a.contractnum,contracttype,vendor,description contractdescription,
currencycode currency,getcontractmaxvol1(a.contractnum,0) originalcontractvalue,
getcontractmaxvol1(a.contractnum,b.revisionnum) currentcontractvalue,
getcontractmaxvol1(a.contractnum,b.revisionnum)-getcontractmaxvol1(a.contractnum,0) changeorders,
(select sum(invoiceamount) from invoicereg where status='PAID'
and contractnum=a.contractnum
and trunc(duedate,'DD')<:startdate
and paymenttype in ('INVOICE','ADVANCE')) invoicedpreviously
,(select sum(invoiceamount) from invoicereg where status='PAID'
and contractnum=a.contractnum
and TRUNC(duedate,'DD')>:startdate
and TRUNC(duedate,'DD')<=:enddate
and paymenttype in ('INVOICE','ADVANCE')) invoicethisperiod
from contract a,
(select contractnum,max(revisionnum) revisionnum from contract
where nvl(projectid,' ') like '%'|| :projectid || '%'
group by contractnum) b
where a.contractnum=b.contractnum
and (a.status='APPR' or a.status='CLOSE')
and nvl(a.projectid,' ') like '%'|| :projectid || '%'
) pay,
(select contractnum,v0,decode(v1,0,'0',v1-v0) V1,decode(v2,0,'0',v2-v1) V2,decode(v3,0,'0',v3-v2) V3,decode(v4,0,'0',v4-v3) V4,decode(v5,0,'0',v5-v4) V5 from
(
select contractnum ,
decode(sign(maxrevisionnum-0+1),1,getcontractmaxvol1(contractnum,0),0) V0,
decode(sign(maxrevisionnum-1+1),1,getcontractmaxvol1(contractnum,1),0) V1,
decode(sign(maxrevisionnum-2+1),1,getcontractmaxvol1(contractnum,2),0) V2,
decode(sign(maxrevisionnum-3+1),1,getcontractmaxvol1(contractnum,3),0) V3,
decode(sign(maxrevisionnum-4+1),1,getcontractmaxvol1(contractnum,4),0) V4,
decode(sign(maxrevisionnum-5+1),1,getcontractmaxvol1(contractnum,5),0) V5
from
(
select contractnum,max(revisionnum) maxrevisionnum from contract group by contractnum
)
))c
where pay.contractnum=c.contractnum AND (PAY.STATUS='APPR' OR PAY.STATUS='CLOSE') |
|