test1.txt 2.4 KB
select * from jwgl_f_t_clxh_workflow_detail a where a.ID_LYSYLB = 36;

select sum(amount - tl_amount) from jwgl_f_t_clxh_workflow_detail
where
to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD')
and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD')

select * from JWGL_D_T_LYSYLB

-- all xh

select
statdateid statdate
, ssjc gs
, xl xl
, zbh cl
, b.SYLB1 || '-' || b.SYLB2 as lylb
, (sum(amount) - sum(tl_amount)) ch
from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b
where
to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD')
and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD')
and a.ID_LYSYLB = b.ID(+)
group by
statdateid
, ssjc
, xl
, zbh
, b.SYLB1 || '-' || b.SYLB2

-- part1

select sum(ch) from
(
select
statdateid statdate
, ssjc gs
, xl xl
, zbh cl
, b.SYLB1 || '-' || b.SYLB2 as lylb
, (sum(amount) - sum(tl_amount)) ch
from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b
where
to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD')
and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD')
and a.ID_LYSYLB = b.ID(+)
group by
statdateid
, ssjc
, xl
, zbh
, b.SYLB1 || '-' || b.SYLB2
)
where lylb in (
'路救-路救',
'小修-小修机工',
'专项-安检',
'专项-节检',
'专项-水箱',
'专项-电瓶',
'小修-小修电工',
'专项-电并',
'小修-小修车身',
'专项-镗固',
'保养-一级保养',
'小修-发动机',
'专项-轮胎',
'分摊-轮胎',
'专项-润滑油',
'总成-差变速',
'总成-大泵',
'总成-小总成',
'总成-发动机',
'保养-二级保养',
'保养-三级保养',
'整修-整修',
'空调-保外',
'空调-保内',
'事故-事故'
)

-- part2

select sum(ch) from
(
select
statdateid statdate
, ssjc gs
, xl xl
, zbh cl
, b.SYLB1 || '-' || b.SYLB2 as lylb
, (sum(amount) - sum(tl_amount)) ch
from JWGL_F_T_CLXH_WORKFLOW_DETAIL a, JWGL_D_T_LYSYLB b
where
to_date(statdateid, 'YYYYMMDD') >= to_date('20170301', 'YYYYMMDD')
and to_date(statdateid, 'YYYYMMDD') <= to_date('20170331', 'YYYYMMDD')
and a.ID_LYSYLB = b.ID(+)
group by
statdateid
, ssjc
, xl
, zbh
, b.SYLB1 || '-' || b.SYLB2
)
where lylb in(
'分摊-镗固',
'专项-机油',
'分摊-机油',
'总成-其它',
'分摊-工具',
'分摊-辅助料',
'分摊-设备',
'车间经费-车间经费'
)