Guest User

Untitled

a guest
Jan 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1.  
  2.  
  3. set @s = '20110201000000';
  4. set @e = '20110301000000';
  5.  
  6. select
  7.  
  8. civicrm.civicrm_country.name as name,
  9. civicrm.civicrm_country.iso_code as iso_code,
  10. sum(not isnull(ecomm.id)) as donations,
  11. sum(total_amount) AS amount
  12.  
  13.  
  14. from
  15. (
  16. select
  17. civicrm.civicrm_contribution.id,
  18. total_amount,
  19. civicrm.civicrm_contribution.contact_id
  20.  
  21. from civicrm.civicrm_contribution
  22. where DATE_FORMAT(receive_date, '%Y%m%d%H%i%s') >= @s and DATE_FORMAT(receive_date, '%Y%m%d%H%i%s') < @e
  23. -- and converted_amount < 10000
  24. ) as ecomm
  25.  
  26. -- left join civicrm.civicrm_contact on ecomm.contact_id = civicrm.civicrm_contact.id
  27. -- left join civicrm.civicrm_address on civicrm.civicrm_contact.id = civicrm.civicrm_address.contact_id
  28. left join civicrm.civicrm_address on ecomm.contact_id = civicrm.civicrm_address.contact_id
  29. left join civicrm.civicrm_country on civicrm.civicrm_address.country_id = civicrm.civicrm_country.id
  30.  
  31. -- where civicrm.civicrm_country.iso_code = 'IN'
  32.  
  33. group by 1,2
  34. order by 1 asc;
Add Comment
Please, Sign In to add comment