Guest User

10G_bára_sql dotazy

a guest
Sep 5th, 2017
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. ----- vypočítej avg / median time frame window trialistů ---------
  2.  
  3. AVG:
  4. select avg(time_frame_window) from v_marketing_reporting_faster where rownumber = '1' and email in ('callsworth11.federico@gmail.com',
  5. 'under0work@gmail.com',
  6. .... /// A DALŠÍ TRIALISTI ////
  7.  
  8. MEDIAN:
  9. select median(time_frame_window) from v_marketing_reporting_faster where email in ('callsworth11.federico@gmail.com',
  10. 'under0work@gmail.com',
  11. .... /// A DALŠÍ TRIALISTI //// )
  12.  
  13. ----- vypočítej avg / median time frame window těch co zaplatili order ---------
  14.  
  15. select median(time_frame_window) from v_marketing_reporting_faster where email not in ('callsworth11.federico@gmail.com',
  16. 'under0work@gmail.com',
  17. .... /// A DALŠÍ TRIALISTI //// -> zde pracujeme s log operandem "NOT" tak tedy zapsat všechny emaily trialistů
  18.  
  19. -------- DALŠÍ SQL MASTEROVINKY ------------------
  20.  
  21. //// vyber nejlepší countries za dané časové období .. DÁ SE BRÁT JAKO LTV //////
  22.  
  23. SELECT DISTINCT short_name AS country,
  24. sum(sum_total)
  25. FROM v_marketing_reporting_faster
  26. WHERE first_payment_date >= '2017-08-01'
  27. AND first_payment_date <= '2017-08-31'
  28. GROUP BY short_name
  29. ORDER BY sum(sum_total) DESC
  30.  
  31. ////
  32.  
  33. ///////// vyber nejlepší zdroje a medium za dané časové období //////
  34. SELECT DISTINCT source, medium,
  35. sum(sum_total)
  36. FROM v_marketing_reporting_faster
  37. WHERE first_payment_date >= '2017-08-01'
  38. AND first_payment_date <= '2017-08-31'
  39. GROUP BY source, medium
  40. ORDER BY sum(sum_total) DESC
  41.  
  42. ////
  43.  
  44. ///////// vyber jen cpc zdroje za dané časové období .. DÁ SE BRÁT JAKO LTV cpc zákošů //////
  45.  
  46. SELECT DISTINCT source, medium,
  47. sum(sum_total)
  48. FROM v_marketing_reporting_faster
  49. WHERE first_payment_date >= '2017-08-01'
  50. AND first_payment_date <= '2017-08-31'
  51. AND medium = 'cpc'
  52. GROUP BY source, medium
  53. ORDER BY sum(sum_total) DESC
  54.  
  55. /////
  56.  
  57.  
  58. ///////// vyber země bez trialů (jen ty s order) //////
  59. SELECT DISTINCT short_name AS country,
  60. sum(sum_total)
  61. FROM v_marketing_reporting_faster
  62. WHERE first_payment_date >= '2017-08-01'
  63. AND first_payment_date <= '2017-08-31'
  64. AND sum_total > 130
  65. GROUP BY short_name
  66. ORDER BY sum(sum_total) DESC
Add Comment
Please, Sign In to add comment