Created
July 30, 2021 12:13
-
-
Save nfriend21/ed95b6587a0f0305439859d17d089a07 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
charges.id, | |
charges.description, | |
charges.captured_at, | |
(amount / 100) as amount, | |
refunded, | |
(charges.amount_refunded / 100) as amount_refunded, | |
subscriptions.plan_id, | |
subscriptions.created, | |
customers.email, | |
customers.id | |
from | |
charges | |
join invoices on charges.invoice_id = invoices.id | |
join subscriptions on invoices.subscription_id = subscriptions.id | |
join customers on invoices.customer_id = customers.id | |
where | |
charges.paid = true | |
AND charges.captured_at > TIMESTAMP '2020-12-01 00:00:00' | |
AND charges.captured_at < TIMESTAMP '2021-01-01 00:00:00' | |
AND (subscriptions.plan_id LIKE '%artist%' OR subscriptions.plan_id LIKE '%print%' OR subscriptions.plan_id LIKE '%professional%' OR subscriptions.plan_id LIKE '%master%' OR subscriptions.plan_id LIKE '%social_pro%' OR subscriptions.plan_id LIKE '%framing_tool%' OR subscriptions.plan_id LIKE '%standard_store%' OR subscriptions.plan_id LIKE '%master%' OR subscriptions.plan_id LIKE '%upload_store%' OR subscriptions.plan_id LIKE '%child%' OR subscriptions.plan_id LIKE '%art_print_store%' OR subscriptions.plan_id LIKE '%lead_capture_tool%' OR subscriptions.plan_id LIKE '%instagram_upload%') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment