Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @s = '20110201000000';
- set @e = '20110301000000';
- select
- civicrm.civicrm_country.name as name,
- civicrm.civicrm_country.iso_code as iso_code,
- sum(not isnull(ecomm.id)) as donations,
- sum(total_amount) AS amount
- from
- (
- select
- civicrm.civicrm_contribution.id,
- total_amount,
- civicrm.civicrm_contribution.contact_id
- from civicrm.civicrm_contribution
- where DATE_FORMAT(receive_date, '%Y%m%d%H%i%s') >= @s and DATE_FORMAT(receive_date, '%Y%m%d%H%i%s') < @e
- -- and converted_amount < 10000
- ) as ecomm
- -- left join civicrm.civicrm_contact on ecomm.contact_id = civicrm.civicrm_contact.id
- -- left join civicrm.civicrm_address on civicrm.civicrm_contact.id = civicrm.civicrm_address.contact_id
- left join civicrm.civicrm_address on ecomm.contact_id = civicrm.civicrm_address.contact_id
- left join civicrm.civicrm_country on civicrm.civicrm_address.country_id = civicrm.civicrm_country.id
- -- where civicrm.civicrm_country.iso_code = 'IN'
- group by 1,2
- order by 1 asc;
Add Comment
Please, Sign In to add comment