create view customer_payment_export_view as
select
fdd.fin_document_key fin_document_key,
fdd.fin_document_detail_key fin_document_detail_key,
null included_fin_document_key,
null invoice_key
from fin_document_detail fdd
join customer_payment cp on cp.fin_document_key = fdd.fin_document_key
union all
select
fin_document_key,
null fin_document_detail_key,
included_fin_document_key,
null invoice_key
from customer_payment_included_pmt
union all
select
fin_document_key,
null fin_document_detail_key,
null included_fin_document_key,
invoice_key
from customer_payment_included_inv
|