Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.23 KB | None | 0 0
  1. SELECT
  2. b.billing_ID as System_Billing_ID,
  3. concat(region.region_code,project.project_code,lpad(b.contract_ID,4,'0'),lpad(b.billing_ID,6,'0')) as Quotation_ID,
  4. concat(contract.contract_name,' ','[',region.region_code,project.project_code,lpad(b.contract_ID,4,'0'),']',' - ',b.billing_month) as Quotation,
  5. b.billing_name as Custom_Name ,b.billing_PO as PO, b.billing_status as Status , b.created_date as Registered_Date ,
  6. media.media_name as Service_Fee ,bd.billing_name as Custom_Name,
  7. bd.billing_billing as Billing , bd.billing_revenue as Revenue , bd.billing_cost as Cost , bd.billing_revenue - bd.billing_cost as Margin , bd.billing_invoice as Invoice_Number,
  8. bd.billing_fee_included as Fee_Included , bd.billing_hide as Billing_Hide , bd.billing_note as Note
  9. FROM mkt_billing_detail bd
  10. right join mkt_billing b on bd.billing_ID = b.billing_ID
  11. inner join mkt_media media on bd.media_ID = media.media_ID
  12. inner join mkt_contract contract on b.contract_ID = contract.contract_ID
  13. inner join mkt_project project on contract.project_ID = project.project_ID
  14. inner join mkt_client cl on project.client_ID = cl.client_ID
  15. inner join mkt_region region on cl.region_ID = region.region_ID
  16. where (b.del != 'Y' and bd.del != 'Y')
  17. order by b.billing_ID desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement