Skip to content

Instantly share code, notes, and snippets.

@Maxhodges
Created June 7, 2018 08:50
Show Gist options
  • Save Maxhodges/0e2f4eeb2ca1944d4d2d57e30f1df233 to your computer and use it in GitHub Desktop.
Save Maxhodges/0e2f4eeb2ca1944d4d2d57e30f1df233 to your computer and use it in GitHub Desktop.
-- This template returns the number of charges and amounts for each card type, by currency
-- Note: if you have currencies that do not have cents (e.g. JPY), you should not divide by 100.0
select
card_country,
count(id) as charge_count,
sum(amount)/100.0 as total_amount
from charges
where captured and card_country in ('AT', 'BE', 'HR', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE',
'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB')
group by 1
order by 3 desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment