Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. select createdLang,
  2. case when email is not null then 'Есть почта' else 'Нет почты' end hasemail,
  3. case when domain = 'gmail.com' then 'gmail.com'
  4. when domain regexp '(^outlook)|(^live)|(^hotmail)' then 'hotmail'
  5. when domain = 'icloud.com' then 'icloud'
  6. when domain regexp '(^bk\.ru)|(^inbox\.ru)|(^list\.ru)|(^mail\.(ru|ua))' then 'mail'
  7. when domain regexp '(^rambler\.ru)|(^ro\.ru)' then 'rambler'
  8. when domain = 'ukr.net' then 'ukr.net'
  9. when domain regexp '(^yahoo\.(.*))' or domain = 'yahoomail.com' then 'yahoo'
  10. when domain regexp '(^ya\.ru)|(^yandex\.(by|com|kz|ru|ua))|(^narod\.ru)' then 'yandex'
  11. when domain is null then 'no email'
  12. else 'others'
  13. end emailservice, -- разбивает по сервисам
  14. case when isconfirm = 1 then 'Подтверждён' when isconfirm = 0 then 'Не подтверждён' end isconfirm,
  15. count(distinct userid) regs, -- кол-во регистрации
  16. count(distinct if(createdsites > 0, userid, null)) completeregs -- кол-во завершённых регистраций,
  17. sum(paymentcount) paymentcount
  18.  
  19. from (
  20. select u._id userid,
  21. u.email,
  22. u.created ucreated,
  23. substring_index(u.email,'@',-1) domain,
  24. count(distinct(if(s._id is not null and s.status > -1, s._id, null))) createdsites,
  25. count(distinct if(b.status = 'paid' and b.amount >= 100 and b.type in ('site') and b.invoicepaidtype = 1, b._id, null)) paymentcount,
  26. u.createdLang,
  27. u.isConfirm,
  28. u.issocialregister
  29. from users u
  30. left join sites s on (u._id = s.userid)
  31. left join billings b on (u._id = b.userid)
  32. where u.isadmin = 0
  33. and u.role = 'guest'
  34. group by u._id
  35. ) sub
  36. group by createdLang, hasemail, emailservice, isconfirm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement