select rownum,
collieryname,
transunitname,
collieryid,
transunitid,
plannum,
truenum,
decode
(substr(arrive, 1, 1), '.', '0' || arrive, arrive) arrive
from (select collieryname,
transunitname,
collieryid,
transunitid,
plannum,
truenum,
arrive
from (select thr2.collieryname,
thr3.transunitname,
thr1.collieryid,
thr1.transunitid,
thr1.plannum,
thr1.truenum,
round(thr1.truenum / thr1.plannum, 3) * 100 arrive
from (select distinct collieryid,
transunitid,
plannum,
truenum
from (select sec1.collieryid,
to_number(sec1.transunitid) transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT, TCOUNT, PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >= '2013-01-25'
and TDATE <= '2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid, t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid = t.truckid
and substr
(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenter t
where SUBSTR(t.tosamtime, 1, 10) >=
'2013-01-25'
and SUBSTR(t.tosamtime, 1, 10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid, t1.transunitid) sec2
where sec1.collieryid = sec2.collieryid(+)
and sec1.transunitid = sec2.transunitid(+)
union all
select sec2.collieryid,
sec2.transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT, TCOUNT, PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >= '2013-01-25'
and TDATE <= '2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid, t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid = t.truckid
and substr(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenterover t
where SUBSTR(t.tosamtime, 1, 10) >=
'2013-01-25'
and SUBSTR(t.tosamtime, 1, 10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid, t1.transunitid) sec2
where sec1.collieryid(+) = sec2.collieryid
and sec1.transunitid(+) = sec2.transunitid)) thr1,
HNDFBPS_FUEL.t_colliery thr2,
HNDFBPS_FUEL.t_transunit thr3
where thr1.collieryid = thr2.id
and thr1.transunitid = thr3.id
union all
select thr2.collieryname || ':合计' ncollieryname,
'' transunitname,
collieryid,
transunitid,
nplannum,
ntruenum,
arrive
from (select collieryid,
0 transunitid,
sum(plannum) nplannum,
sum(truenum) ntruenum,
round(sum(truenum) / sum(plannum), 3) * 100 arrive
from (select distinct collieryid,
transunitid,
plannum,
truenum
from (select sec1.collieryid,
to_number(sec1.transunitid) transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT,
TCOUNT,
PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >=
'2013-01-25'
and TDATE <=
'2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid,
t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid =
t.truckid
and substr(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenter t
where SUBSTR(t.tosamtime,
1,
10) >=
'2013-01-25'
and SUBSTR(t.tosamtime,
1,
10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid,
t1.transunitid) sec2
where sec1.collieryid =
sec2.collieryid(+)
and sec1.transunitid =
sec2.transunitid(+)
union all
select sec2.collieryid,
sec2.transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT,
TCOUNT,
PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >=
'2013-01-25'
and TDATE <=
'2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid,
t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid =
t.truckid
and substr(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenterover t
where SUBSTR(t.tosamtime,
1,
10) >=
'2013-01-25'
and SUBSTR(t.tosamtime,
1,
10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid,
t1.transunitid) sec2
where sec1.collieryid(+) =
sec2.collieryid
and sec1.transunitid(+) =
sec2.transunitid)) tem1
group by tem1.collieryid) thr1,
HNDFBPS_FUEL.t_colliery thr2
where thr1.collieryid = thr2.id
union all
select '总合计' ncollieryname,
'' transunitname,
collieryid,
transunitid,
nplannum,
ntruenum,
arrive
from (select 0 collieryid,
0 transunitid,
sum(plannum) nplannum,
sum(truenum) ntruenum,
round(sum(truenum) / sum(plannum), 3) * 100 arrive
from (select distinct collieryid,
transunitid,
plannum,
truenum
from (select sec1.collieryid,
to_number(sec1.transunitid) transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT,
TCOUNT,
PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >=
'2013-01-25'
and TDATE <=
'2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid,
t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid =
t.truckid
and substr(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenter t
where SUBSTR(t.tosamtime,
1,
10) >=
'2013-01-25'
and SUBSTR(t.tosamtime,
1,
10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid,
t1.transunitid) sec2
where sec1.collieryid =
sec2.collieryid(+)
and sec1.transunitid =
sec2.transunitid(+)
union all
select sec2.collieryid,
sec2.transunitid,
plannum,
truenum
from (select t2.collieryid,
to_number(t1.TRANSUNIT) transunitid,
sum(t1.TCOUNT) plannum
from (select TRANSUNIT,
TCOUNT,
PLANID
from HNDFBPS_FUEL.T_TRUCKBILL
where TDATE >=
'2013-01-25'
and TDATE <=
'2013-01-25') t1,
HNDFBPS_FUEL.t_truckcoalplan t2,
HNDFBPS_fuel.T_TRUCKATTEMPPLAN t3
where t1.PLANID = t3.id
and t3.TRUCKCOALPLANID = t2.id
group by t2.collieryid,
t1.TRANSUNIT) sec1,
(select count(id) truenum,
collieryid,
transunitid
from (select collieryid,
t.id,
(select transunitid
from HNDFBPS_FUEL.t_truckbelong
where truckid =
t.truckid
and substr(tosamtime,
1,
10) >=
starttime
and substr(tosamtime,
1,
10) <=
stoptime) transunitid
from HNDFBPS_FUEL.t_truckenterover t
where SUBSTR(t.tosamtime,
1,
10) >=
'2013-01-25'
and SUBSTR(t.tosamtime,
1,
10) <=
'2013-01-25'
and t.eweighttime is not null) t1
group by t1.collieryid,
t1.transunitid) sec2
where sec1.collieryid(+) =
sec2.collieryid
and sec1.transunitid(+) =
sec2.transunitid)) sec1) thr1)
order by collieryname)