Guest User

Untitled

a guest
Apr 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. Select
  2. b.name As BrokerName,
  3. c.customer_name As CustomerName,
  4. s.utility_account As UtilityAccountNumber,
  5. b1.invoice_number As b1InvoiceNumber,
  6. b1.invoice_date As b1InvoiceDate,
  7. b1.billing_amount_due As b1AmountBilled,
  8. b2.invoice_number As b2InvoiceNumber,
  9. b2.invoice_date As b2InvoiceDate,
  10. b2.billing_amount_due As b2AmountBilled,
  11. b3.invoice_number As b3InvoiceNumber,
  12. b3.invoice_date As b3InvoiceDate,
  13. b3.billing_amount_due As b3AmountBilled,
  14. b4.invoice_number As b4InvoiceNumber,
  15. b4.invoice_date As b4InvoiceDate,
  16. b4.billing_amount_due As b4AmountBilled,
  17. b5.invoice_number As b5InvoiceNumber,
  18. b5.invoice_date As b5InvoiceDate,
  19. b5.billing_amount_due As b5AmountBilled
  20. From customers As c
  21. Left Join service_locations As s On s.customer_id=c.numeric_id
  22. Left Join sales_person As p On p.customer_id=s.customer_id
  23. Left Join brokers As b On b.numeric_id=p.broker_id_primary
  24. Left Join billings As b1 On b1.utility_acct=s.utility_account and b1.invoice_date Between '2011-06-01' And Last_Day('2011-06-01') and b1.status!='Rejected'
  25. Left Join billings As b2 On b2.utility_acct=s.utility_account and b2.invoice_date Between '2011-07-01' And Last_Day('2011-07-01') and b2.status!='Rejected'
  26. Left Join billings As b3 On b3.utility_acct=s.utility_account and b3.invoice_date Between '2011-08-01' And Last_Day('2011-08-01') and b3.status!='Rejected'
  27. Left Join billings As b4 On b4.utility_acct=s.utility_account and b4.invoice_date Between '2011-09-01' And Last_Day('2011-09-01') and b4.status!='Rejected'
  28. Left Join billings As b5 On b5.utility_acct=s.utility_account and b5.invoice_date Between '2011-10-01' And Last_Day('2011-10-01') and b5.status!='Rejected'
  29. Where b.mlm_signup=1 and s.utility_account ='008535799972';
Add Comment
Please, Sign In to add comment