ahmedrahil786

Daily payment Reject Cases - Rahil

Dec 27th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. ############# Monthly Query for Payment Provider
  2.  
  3.  
  4.  
  5. set @startdate1 = '2019-01-01';
  6. set @startdate2 = '2019-12-31';
  7. Select
  8. date(A.start_Date) as month,
  9. year(A.start_Date) as year,
  10. Count(Distinct A.rid) as Total_attempts,
  11. count(distinct case when A.provider = 'mcp' then A.rid end) as Total_MCP,
  12. count(distinct case when A.provider = 'braintree' then A.rid end) as Total_braintree,
  13. count(distinct case when A.provider = 'grabpay' then A.rid end) as Total_grabpay,
  14. count(distinct case when A.provider = 'stripe' then A.rid end) as Total_stripe,
  15. count(distinct case when A.provider = 'mcp' and A.state not in ('fail') then A.rid end) as MCP_Good,
  16. count(distinct case when A.provider = 'braintree' and A.state not in ('fail') then A.rid end) as braintree_Good,
  17. count(distinct case when A.provider = 'grabpay' and A.state not in ('fail') then A.rid end) as grabpay_Good,
  18. count(distinct case when A.provider = 'stripe' and A.state not in ('fail') then A.rid end) as stripe_Good,
  19. count(distinct case when A.provider = 'mcp' and A.state in ('fail') then A.rid end) as MCP_failed,
  20. count(distinct case when A.provider = 'braintree' and A.state in ('fail') then A.rid end) as braintree_failed,
  21. count(distinct case when A.provider = 'grabpay' and A.state in ('fail') then A.rid end) as grabpay_failed,
  22. count(distinct case when A.provider = 'stripe' and A.state in ('fail') then A.rid end) as stripe_failed
  23. from
  24. (select
  25. distinct r.id as rid, r.member_id as mid, r.state as state, p.paid_type as type, pm.provider as provider,
  26. Date(r.created_at + interval '8' hour) as start_Date, p.paygate as provider_2
  27. from reservations r left join members m on r.member_id = m.id
  28. LEFT JOIN payment_methods pm ON r.payment_method_id = pm.id
  29. left join payments p on p.reservation_id = r.id
  30. where r.created_at + interval 8 hour >= @startdate1
  31. and r.created_at + interval 8 hour <= @startdate2
  32. and r.member_id not in ('125', '127')
  33. group by rid, type) A
  34. group by 1
  35. order by 1 desc;
Advertisement
Add Comment
Please, Sign In to add comment