Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. SELECT a.id, testgroup, testtime, user_age, overall_payments, partial_payments, avg_session_length, avg_num_sessions, num_actdays, crystals_spend, overall_complexity_covered, sum(coalesce(complexity,0)) as partial_complexity_covered
  2. FROM ( SELECT a.id, testgroup, testtime, user_age, overall_payments, partial_payments, avg_session_length, avg_num_sessions, num_actdays, sum(coalesce(buy_value,0)) as crystals_spend
  3. FROM ( SELECT a.id, testgroup, testtime, user_age, overall_payments, partial_payments, coalesce(avg(session_length/1.0),0) as avg_session_length, coalesce(cast(count(b.id) as real))/(case when count(distinct actdate)=0 or count(distinct actdate) is null then 1 else count(distinct actdate) end) as avg_num_sessions,
  4. coalesce(count(distinct actdate),0) as num_actdays
  5. FROM ( SELECT a.id, testgroup, testtime, testdate-regdate as user_age, coalesce(overall_payments,0) as overall_payments, sum(coalesce(real_value,0))/100.0 as partial_payments
  6. FROM ( SELECT id, app_version as testgroup, utc_timestamp as testtime, date(TIMESTAMP 'epoch' + utc_timestamp * INTERVAL '1 second') as testdate
  7. FROM ext_master.mghost_mcpu a WHERE app_version = '2.36' and socnet='2ios' and utc_timestamp > 1513122772 - 1800 and utc_timestamp < 1513122824 + 1800
  8. and id not in (SELECT id FROM temp.mghost_ab_versions_371_36_payers) ) a
  9. join ( SELECT *, date(TIMESTAMP 'epoch' + utc_timestamp * INTERVAL '1 second') as regdate FROM master.mghost_personal_info_new WHERE socnet='2ios' ) b on a.id = b.id
  10. LEFT OUTER JOIN ( SELECT id, sum(real_value/100.0) as overall_payments
  11. FROM master.mghost_payments WHERE payment_method not in ('offer_wall', 'fb_promotion') and socnet='2ios' GROUP BY 1 ) c on a.id = c.id
  12. LEFT OUTER JOIN ( SELECT id, real_value, utc_timestamp as buytime FROM master.mghost_payments WHERE payment_method not in ('offer_wall', 'fb_promotion') and socnet='2ios' ) d on a.id = d.id and testtime-coalesce(buytime, 0)>=0 and testtime-coalesce(buytime, 100000000000000)<=86400*14 GROUP BY 1,2,3,4,5 ) a
  13. LEFT OUTER JOIN ( SELECT id, session_length, session_start_time, actdate FROM master.mghost_sessions WHERE current_date-actdate<=14 and socnet='2ios' ) b on a.id = b.id and testtime-coalesce(session_start_time, 0)>=0 and testtime-coalesce(session_start_time, 100000000000000)<=86400*14 WHERE overall_payments > 0 GROUP BY 1,2,3,4,5,6 ) a
  14. LEFT OUTER JOIN ( SELECT a.id, utc_timestamp as crtime, buy_value FROM ( SELECT id, item_count, md5(id+socnet+utc_timestamp+coalesce(source,'')+coalesce(subsource,'')+coalesce(subject,'')+coalesce(subsubject,'')+coalesce(balance,0)+item_count) as row_hash
  15. FROM ext_master.mghost_hard_currency
  16. WHERE current_date-actdate<=100 and event='spend' and item_count>0 and socnet='2ios' ) a j
  17. oin ( SELECT * FROM ghosts_mobile.hard_currency_real_attr ) b on a.row_hash = b.row_hash ) b on a.id = b.id and testtime-coalesce(crtime, 0)>=0 and testtime-coalesce(crtime, 100000000000000)<=86400*14 GROUP BY 1,2,3,4,5,6,7,8,9 ) a
  18. LEFT OUTER JOIN ( SELECT a.id, complexity, utc_timestamp as mtime FROM ext_master.mghost_content_conversion a
  19. join ( SELECT * FROM ghosts_mobile.mghost_clusters WHERE monetization_flag=1) b on a.content_name=b.source WHERE event='finish' and current_date-actdate<=30 and socnet='2ios' ) b on a.id = b.id and testtime-coalesce(mtime, 0)>=0 and testtime-coalesce(mtime, 100000000000000)<=86400*14
  20. LEFT OUTER JOIN ( SELECT a.id, sum(complexity) as overall_complexity_covered FROM ext_master.mghost_content_conversion a
  21. join ( SELECT * FROM ghosts_mobile.mghost_clusters WHERE monetization_flag=1) b on a.content_name=b.source WHERE event='finish' and socnet='2ios' GROUP BY a.id ) c on a.id = c.id GROUP BY 1,2,3,4,5,6,7,8,9,10,11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement