Skip to content

Instantly share code, notes, and snippets.

@marzzz21
Created February 8, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marzzz21/72620ea8c54c136f2c77909f63d9dad2 to your computer and use it in GitHub Desktop.
Save marzzz21/72620ea8c54c136f2c77909f63d9dad2 to your computer and use it in GitHub Desktop.
SELECT fm.user_id, fm.send_to as number, fma.result, fma.scheduled_start_time, fma.total_fax_duration, (SELECT t.amount from chargeable chrgble left join transactable trnsctble on chrgble.id = trnsctble.id left join transaction_reference tr on trnsctble.id = tr.transaction_item_id left join transaction t on tr.id = t.reference_id WHERE t.credit_bank_id IN (SELECT credit_bank.id from credit_bank left join money_credit_bank on credit_bank.id = money_credit_bank.id where t.credit_bank_id = credit_bank.id) As user_charged FROM fax_message_attempt fma LEFT JOIN fax_message fm on fma.fax_message_id = fm.id WHERE fma.result IS NOT NULL and fm.status = 'DONE' AND fma.scheduled_start_time >= $1 AND fma.scheduled_start_time < $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment