Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select
- b.name As BrokerName,
- c.customer_name As CustomerName,
- s.utility_account As UtilityAccountNumber,
- b1.invoice_number As b1InvoiceNumber,
- b1.invoice_date As b1InvoiceDate,
- b1.billing_amount_due As b1AmountBilled,
- b2.invoice_number As b2InvoiceNumber,
- b2.invoice_date As b2InvoiceDate,
- b2.billing_amount_due As b2AmountBilled,
- b3.invoice_number As b3InvoiceNumber,
- b3.invoice_date As b3InvoiceDate,
- b3.billing_amount_due As b3AmountBilled,
- b4.invoice_number As b4InvoiceNumber,
- b4.invoice_date As b4InvoiceDate,
- b4.billing_amount_due As b4AmountBilled,
- b5.invoice_number As b5InvoiceNumber,
- b5.invoice_date As b5InvoiceDate,
- b5.billing_amount_due As b5AmountBilled
- From customers As c
- Left Join service_locations As s On s.customer_id=c.numeric_id
- Left Join sales_person As p On p.customer_id=s.customer_id
- Left Join brokers As b On b.numeric_id=p.broker_id_primary
- 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'
- 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'
- 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'
- 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'
- 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'
- Where b.mlm_signup=1 and s.utility_account ='008535799972';
Add Comment
Please, Sign In to add comment