select r.revenue_status,
decode(r.transfer_status_code, 'R', r.transfer_rejection_reason, nvl(trr.meaning,r.transfer_rejection_reason))
transfer_rejection_reason,
lka.meaning action,
r.pa_date,r.project_number,r.draft_revenue_num revenue_number,r.amount
from pa_proj_revenue_view r
,pa_lookups lka
,pa_lookups lkb
,pa_lookups trr
where trunc(r.pa_date) between :pa_date_low and :pa_date_high
and r.pa_date >= to_date('19000101','YYYYMMDD')
and r.transfer_status_code = nvl(:transfer_status,r.transfer_status_code)
and r.transfer_status_code != decode(:include_acc_rev,'N','A', 'No', 'A', 'NO', 'A', 'nO', 'A', 'Z')
and lkb.lookup_type(+)='INVOICE/REVENUE STATUS'
and lkb.meaning = r.revenue_status
and lka.lookup_type='REVENUE ACTIONS'
and lka.lookup_code=lkb.lookup_code(+)
and trr.lookup_type(+)='REVENUE DIST REJECTION CODE'
and trr.lookup_code(+)=r.transfer_rejection_reason
ORDER BY 1 ASC,r.pa_date,r.project_number,r.draft_revenue_num |