Created
March 1, 2017 10:42
-
-
Save anonymous/bec2ad716ed4b71ca1c9fbb94138f296 to your computer and use it in GitHub Desktop.
invoices-sipwise-sent SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
ctr.id as cliid, | |
inv.id as invid, | |
date_format(period_start,'%Y%m') as inici, | |
date_format(period_end,'%Y%m') as fi, | |
round(amount_total,2) as total, | |
sent_date as enviat, | |
cnt.email as email, | |
concat(cnt.firstname,' ',cnt.lastname) as customer | |
from billing.contracts as ctr | |
left join billing.contacts as cnt on ctr.contact_id = cnt.id | |
left join billing.invoices as inv on ctr.id = inv.contract_id | |
where | |
ctr.status='active' and | |
ctr.external_id is not null | |
and inv.period_start >= '2017-01-01 00:00:00' | |
and inv.period_end <= '2017-02-01 00:00:00' | |
order by ctr.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment