Code: Alles auswählen.
SELECT FROM tiban
LEFT OUTER JOIN febep
ON tiban~iban = febep~piban
LEFT OUTER JOIN dpayh
ON tiban~iban = dpayh~ziban
LEFT OUTER JOIN reguh
ON tiban~iban = reguh~ziban
FIELDS iban,
MAX( febep~budat ) as deposit,
MAX( dpayh~laufd ) as debit_charge,
MAX( reguh~laufd ) as payout
" höchter Wert der drei Datumsspalten in extra Spalte
WHERE iban IN @mrt_iban[]
GROUP BY iban,
INTO TABLE @DATA(lt_join).
Code: Alles auswählen.
define view zpayments as select from febep{
key iban,
budat
} union select from dpayh {
key iban,
laufd as budat
}union select from reguh {
key iban,
laufd as budat
}
Code: Alles auswählen.
define view zlast_payment as select from tiban as i
association to zpayments as p on p.iban = i.iban
association to febep as d on d.iban = i.iban
association to dpayh as dc on dc.iban = i.iban
association to reguh as po on po.iban = i.iban{
key i.iban,
max( d.budat ) as deposit,
max( dc.laufd ) as depit_charge,
max( po.laufd ) as payout,
max( p.budat ) as last_posting_date
} group by i.iban