[load_grdList]
select
	 tkb.CD_CUSTOMER
	,mc.NAME_CUSTOMER
	--#24442 2022.06.18 MOD STT
--	,substr(tkb.DT_BUNDLE, 1, 10) DT
	,to_char(tkb.DT_BUNDLE, 'YYYYMMDD') DT
	--#24442 2022.06.18 MOD END
	,tkb.DTS_YEAR
	,tkb.DTS_MONTH
	,tkb.DTS_DAY
FROM T_KANRI_BUNDLE tkb
left join M_CUSTOMER mc on tkb.CD_CUSTOMER = mc.CD_CUSTOMER
left join(
	select CD_CUSTOMER
		,DT_SEIKYU
	from T_SEIKYU_TBL
	group by CD_CUSTOMER , DT_SEIKYU
) tst on tkb.CD_CUSTOMER = tst.CD_CUSTOMER and tkb.DT_BUNDLE = tst.DT_SEIKYU
where tkb.DTS_YEAR = ':dtsYear'
and tkb.DTS_MONTH = ':dtsMonth'
and tkb.DTS_DAY = ':dtsDay'
and tkb.FLG_DELETE = 0
--#24442 2022.06.18 MOD STT
--and ((':cdCustomer' is null) or (tkb.CD_CUSTOMER = ':cdCustomer'))
and ((':cdCustomer' = '') or (tkb.CD_CUSTOMER = to_number(':cdCustomer')))
--#24442 2022.06.18 MOD END
and tst.CD_CUSTOMER is not null
and mc.DT_START <= to_date(':dts_year' || lpad(':dts_month' , 2, '0') || lpad(':dts_day', 2, '0'))
and mc.DT_END >= to_date(':dts_year' || lpad(':dts_month' , 2, '0') || lpad(':dts_day', 2, '0'))
and mc.FLG_DELETE = 0
order by tkb.CD_CUSTOMER

