ECC Lease Contracts, Lease Invoice Information, SQL1

Description
Columns: Ecc Spec Id, Invoice Num, Customer Name, Site Use Id, Currency Code, Due Date, Amount, Balance, Ar Invoice Id, Usage Period ...
Imported from ECC
select * from (SELECT  distinct
      oec.ecc_spec_id
     ,oec.invoice_num
     ,oec.customer_name
     ,oec.site_use_id
     ,oec.currency_code
     ,oec.due_date
     ,oec.amount
     ,oec.balance
     ,oec.ar_invoice_id
     ,oec.usage_period
     ,oec.invoice_date
	   ,oec.bill_to_site_use_id
  	 ,oec.customer_acct_id
     ,oec.org_id
     ,oec.CUSTOMER_NUMBER
     ,oec.contract_number
     ,oec.asset_number
     ,payout_basis.description payout_basis
     ,payment_basis.description payment_basis
     ,payout_basis.language
     ,oec.contract_id
   	 ,oec.invoice_line_number
     ,oec.line_type
     ,oec.line_amount
     ,oec.tax_amount
	   ,oec.revenue_amount
  	 ,oec.amount_due_remaining
     ,oec.receivable_application_id
     ,oec.cash_receipt_id
     ,oec.customer_trx_id
     ,oec.customer_trx_line_id
     ,oec.invoice_number
     ,oec.stream_type
		 ,oec.due_date_receipt
     ,oec.balance_amount
     ,oec.applied_amount
     ,oec.line_applied
     ,oec.tax_applied
     ,oec.line_balance
     ,oec.tax_balance
     ,oec.original_applied_amount
     ,oec.total_line_amount
     ,oec.gl_date
		 ,oec.invoice_currency_code
     ,oec.receipt_number
		 ,oec.TAX_CURRENT_AMOUNT_DUE
		 ,oec.ORIGINAL_LINE_APPLIED
		 ,oec.ORIGINAL_TAX_APPLIED
		 ,oec.ORIGINAL_GL_DATE
     ,oec.vendor
     ,oec.vendor_site
		 ,oec.ar_link
     ,oec.ap_inv_num
     ,oec.invoice_amount
     ,oec.line_number
     ,oec.ap_line_amount
     ,oec.ap_tax_amount
     ,oec.payment_date
     ,oec.payment_number
     ,oec.ap_inv_date
     ,oec.paid_amount
     ,oec.receipt_date
FROM  okl_ecc_charges_data oec
       ,fnd_lookup_values payout_basis
       ,fnd_lookup_values payment_basis
WHERE   payout_basis.lookup_code = oec.payout_basis
AND     payout_basis.lookup_type = 'OKL_PAYOUT_BASIS'
AND     payment_basis.lookup_code = oec.payment_basis
AND     payment_basis.lookup_type = 'OKL_PAYMENT_BASIS'
AND     payment_basis.language = payout_basis.language
AND     payment_basis.language in ('US')
AND     oec.spec_flag ='N')
 PIVOT
			        (MAX(payout_basis) AS payout_basis,
							 MAX(payment_basis) AS payment_basis
			         for language in('US' "US"))