Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. (CountCurrent - CountLastMonth) / CountLastMonth
  2.  
  3. activity, upload_date
  4.  
  5. SELECT
  6. Y.CurrentMonth, Y.CountCurrent,
  7. Z.LastMonth, Z.CountLastMonth
  8.  
  9.  
  10. FROM
  11. (SELECT
  12. upload_date,
  13. activity,
  14. DATE_FORMAT(upload_date,'%M %Y') AS CurrentMonth,
  15. COUNT(activity) AS CountCurrent
  16. FROM appmaster
  17. WHERE activity = 'com.google.test'
  18. GROUP BY DATE_FORMAT(upload_date,'%m%y'))
  19. Y INNER JOIN
  20. (SELECT
  21. activity,
  22. DATE_FORMAT(upload_date,'%M %Y') AS CurrentMonth2,
  23. DATE_FORMAT(upload_date - INTERVAL 1 MONTH,'%M %Y') AS LastMonth,
  24. COUNT(activity) AS CountLastMonth
  25. FROM appmaster
  26. WHERE activity = 'com.google.test'
  27. GROUP BY DATE_FORMAT(upload_date - INTERVAL 1 MONTH,'%m%y'))
  28. Z ON Z.CurrentMonth2 = Y.CurrentMonth
  29.  
  30. GROUP BY DATE_FORMAT(upload_date,'%Y%m')
  31. ORDER BY DATE_FORMAT(upload_date,'%Y%m')
  32.  
  33. SELECT b.CurrentMonth, sum(b.CountCurrent), b.LastMonth
  34. FROM (SELECT DATE(a.upload_date - INTERVAL 1 MONTH) AS LastMonth, DATE(a.upload_date) AS CurrentMonth, COUNT(a.activity) AS CountCurrent
  35. FROM appmaster a WHERE a.activity = 'com.google.android.googlequicksearchbox'
  36. group BY MONTH(a.upload_date)) AS b
  37.  
  38. group BY MONTH(b.CurrentMonth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement