select r1.ccsl, r2.jhsl, r3.rksl, r4.pcsl, r5.kpsl, r6.Jhsj, r7.kpsj, r8.rksj, r9.ccsj, r10.wlsj from (
	select 'a' as r1, 'b' as r2
) a 
left join (
	select sum(lfimg) as ccsl from lips where vgbel = '' and vgpos = '' and mandt = '800'
) r1 on 1=1

left join (
		select sum(Bmeng) as jhsl from vbep where vbeln = '' and posnr = '' and mandt = '800'
) r2 on 1=1

left join (
	select sum(wemng) as rksl from afpo where kdauf = '' and kdpos = '' and mandt = '800'
) r3 on 1=1

left join (
	select sum(psmng) as pcsl from afpo where kdauf = '' and kdpos = '' and mandt = '800'
) r4 on 1=1

left join (
	select sum(q.fkimg) as kpsl from vbap p
	left join (
		select b.fkimg, b.aubel, b.aupos, a.mandt from vbrk a
		left join vbrp b on a.vbeln = b.vbeln and a.mandt = b.mandt
		where a.mandt is not null and b.mandt is not null and a.fkart not in ('ZIV1', 'ZIVR')
		group by b.fkimg, b.aubel, b.aupos, a.mandt
	) q on p.vbeln = q.aubel and p.mandt = q.mandt and p.posnr = q.aupos
	where p.vbeln = '' and p.posnr = '' and p.mandt = '800' and p.erdat1 = '2020-10-31'
) r5 on 1=1

left join (
	select max(edatu1) as Jhsj from vbep where vbeln = '' and posnr = '' and mandt = '800'
) r6 on 1=1

left join (
	select max(r.kpsj) as kpsj from (
	select a.vbeln, a.posnr, a.mandt, a.erdat1, b.kpsj from vbap a
	left join (
		select aa.vbeln, aa.posnr, aa.mandt, bb.kpsj from lips aa
			left join (
				select aaa.vgbel,aaa.vgpos,aaa.vbeln,aaa.mandt,bbb.kpsj from Vbrp aaa
				left join (
					select vbeln, mandt, max(Fkdat1) as kpsj from vbrk group by vbeln, mandt
				) bbb on aaa.vbeln = bbb.vbeln and aaa.mandt = bbb.mandt
			) bb on aa.vbeln = bb.vgbel and aa.posnr = bb.vgpos and aa.mandt = bb.mandt
	) b on a.vbeln = b.vbeln and a.posnr = b.posnr and a.mandt = b.mandt
	where a.vbeln = '' and a.posnr = '' and a.mandt = '800' and a.erdat1 = '2020-10-31'
	) r
) r7 on 1=1

left join (
	select max(r.rksj) as rksj from (
	select a.vbeln, a.posnr, a.mandt, a.erdat1, b.rksj from vbap a
	left join (
		select aa.kdauf,aa.kdpos,aa.mandt,aa.aufnr,bb.rksj from afpo aa
		left join (
			select aaa.aufnr,aaa.mandt,bbb.rksj from afko aaa
			left join (
				select aufnr,mandt,max(budat1) as rksj from aufm where budat1 is not null group by aufnr,mandt
			) bbb on aaa.aufnr = bbb.aufnr and aaa.mandt = bbb.mandt
			where bbb.rksj is not null
		) bb on aa.aufnr = bb.aufnr and aa.mandt = bb.mandt
		where bb.rksj is not null
	) b on a.vbeln = b.kdauf and a.posnr = b.kdpos and a.mandt = b.mandt
	where a.vbeln = '' and a.posnr = '' and a.mandt = '800' and a.erdat1 = '2020-10-31' and b.rksj is not null
	) r
)r8 on 1=1

left join (
select max(r.already_ready_time) as ccsj from (
select a.vbeln, a.posnr, a.mandt, a.erdat1, b.already_ready_time from vbap a
left join (
	select aa.vbeln, aa.posnr, aa.mandt, bb.already_ready_time from lips aa
	left join (
		select aaa.vbeln,aaa.mandt,bbb.already_ready_time from likp aaa
		left join (
			select vbeln,max(already_ready_time) as already_ready_time from handover group by vbeln
		) bbb on aaa.vbeln = bbb.vbeln
	) bb on aa.vbeln = bb.vbeln and aa.mandt = bb.mandt
) b on a.vbeln = b.vbeln and a.posnr = b.posnr and a.mandt = b.mandt
where a.vbeln = '' and a.posnr = '' and a.mandt = '800' and a.erdat1 = '2020-10-31'
) r

) r9 on 1=1

left join (
select max(r.sign_time) as wlsj from (
select a.vbeln, a.posnr, a.mandt, a.erdat1, b.sign_time from vbap a
left join (
	select aa.vbeln, aa.posnr, aa.mandt, bb.sign_time from lips aa
	left join (
		select aaa.vbeln,aaa.mandt,bbb.sign_time from likp aaa
		left join (
			select vbeln,max(sign_time) as sign_time from handover group by vbeln
		) bbb on aaa.vbeln = bbb.vbeln
	) bb on aa.vbeln = bb.vbeln and aa.mandt = bb.mandt
) b on a.vbeln = b.vbeln and a.posnr = b.posnr and a.mandt = b.mandt
where a.vbeln = '' and a.posnr = '' and a.mandt = '800' and a.erdat1 = '2020-10-31'
) r

) r10 on 1=1
