select 
tbk_booking_number, tbk_date, tbk_created_by, TBK_CREATED_ON,tbrd_system,
decode(tbk_next_process_number,3,'OPEN',4,'Partially Supplied',5,'Fully Supplied',6,'Partially Invoiced','Fully Invoiced') bk_status,
(Select tbrd_invoice from ke074t3.bcd_ict_tour_sv_and_invoices where INV_Branch='SAFCOM' and INV_BK=TBK_BOOKING_NUMBER and INV_SV=tbrd_system and rownum=1) INV_NO2,
(select BPV_number from ke074t3_support.BCD_AUDIT_PAID_SV_VIEW_2 where sv_number=tbrd_system and rownum=1)
from ke074t3.id_tb_booking_header,ke074t3.id_tb_booking_rate_details where tbk_date<='01-jun-2018'
and tbk_reference=tbrd_reference
and tbrd_sys_type='SV'
and tbrd_status<>'V'


