ahmedrahil786

Local Vs International - Rahil

Mar 24th, 2020 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. select distinct r.member_id as mid,
  2. ma.country as country,
  3. if(ma.country = 'MYS','local','international') as region
  4. from reservations r
  5. left join members m on m.id = r.member_id
  6. left join member_appendixes ma on ma.member_id = m.id
  7. where m.imaginary in ('sofam', 'normal')
  8. and r.member_id not in ('125', '127')
  9. #and ma.country not like 'MYS'
  10. group by 1 ;
  11.  
  12. select
  13. ROUND(count(distinct case when A.region = 'international' then A.mid end)*100/count(distinct A.mid),2) as international_PCT,
  14. ROUND(count(distinct case when A.region = 'local' then A.mid end)*100/count(distinct A.mid),2) as local_PCT
  15. from
  16. (select distinct r.member_id as mid,
  17. ma.country as country,
  18. if(ma.country = 'MYS','local','international') as region
  19. from reservations r
  20. left join members m on m.id = r.member_id
  21. left join member_appendixes ma on ma.member_id = m.id
  22. where m.imaginary in ('sofam', 'normal')
  23. and r.member_id not in ('125', '127')
  24. #and ma.country not like 'MYS'
  25. group by 1) A
  26.  
Add Comment
Please, Sign In to add comment