Select
extract(year from tbk_date) Year,
extract(month from tbk_date) mOnth,
tbk_customer customer,
Replace(replace(replace(replace(replace(replace((select ar_name from id_ar_master where ar_code=tbk_customer and rownum=1),',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') CUST_NAME,
Tbk_date Booking_Date,
Replace(replace(replace(replace(replace(replace(TBK_TMP_CUST_NAME,',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') Pax_Name,
TBK_EXECUTIVE_CODE BCD_TC, 
Replace(replace(replace(replace(replace(replace((select upper( EXEC_NAME)  from ID_EXECUTIVE_MASTER where TBK_EXECUTIVE_CODE=EXEC_CODE),',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') BCD_TC_Name,
tbrd_system SV_Number, 
TBK_BOOKING_NUMBER Booking_Nr, 
TBRD_PROVIDER Provider, 
Replace(replace(replace(replace(replace(replace((select tbpm_name from id_tb_provider_master where tbpm_provider=tbrd_provider and rownum=1),',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') Provider_Name,
tbrd_supplier,
Replace(replace(replace(replace(replace(replace((select tbpm_name from id_tb_provider_master where tbpm_provider=tbrd_supplier and rownum=1),',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') Supplier_Name,
TBRD_SERVICE Service, 
TBRD_FROM_DATE Check_in_Date,
TBRD_TO_DATE Check_Out_Date, 
(TBRD_TO_DATE-TBRD_FROM_DATE) BK_NIGHTS,
TBRD_PROVIDER_CURRENCY PROV_CCY, TBRD_PROVIDER_RATE Unit_Rate,  TBRD_NO_OF_UNITS Units,TBRD_MARKUP_METHOD, TBRD_MARKUP_VALUE,  TBRD_DISCOUNT_METHOD, TBRD_DISCOUNT_VALUE,TBRD_INVOICE_VALUE INV_Value, TBRD_CURRENCY CCY,TBRD_COST_F_AMOUNT Cost_F_Amount, TBRD_EX_RATE EX_Rate, TBRD_COST_L_AMOUNT Local_amount,
--(select TBRD_INVOICE from bcd_ict_tour_sv_and_invoices where inv_sv=tbrd_system and rownum=1) INV_NO,
--(select TBRD_INVOICE_F_AMOUNT from bcd_ict_tour_sv_and_invoices where inv_sv=tbrd_system and rownum=1) INV_F_AMOUNT,
Replace(replace(replace(replace(replace(replace((SELECT TBSM_SERVICE_TYPE FROM id_tb_service_master WHERE TBSM_SERVICE_CODE=TBRD_SERVICE AND ROWNUM=1),',','-'),'/','-'),chr(9),'-'),chr(10),'-'),chr(13),'-') ,'.','-') SERVICE_CLASS
from 
id_tb_booking_rate_details,
id_tb_booking_header
where
TBRD_REFERENCE=TBK_REFERENCE
and TBRD_SYS_TYPE='SV'
and tbrd_status<>'V'
order by tbrd_system
