keywords_growth.sql 710 B

123456789101112131415161718192021222324
  1. # hhh流量週報的SQL cmd
  2. # 本週關鍵字點擊成長
  3. # 不太懂為什麼要一直洗掉。
  4. -- select
  5. -- weeknum, id
  6. -- from
  7. -- hhh.hhh_weekly_keywords
  8. # 先找尋不同週的兩個table
  9. -- select * from hhh.hhh_weekly_keywords where weeknum=26;
  10. select
  11. A.query, A.clicks, A.ctr, A.impressions, A.weeknum,
  12. B.weeknum, B.clicks, B.ctr, B.impressions,
  13. ((A.clicks-B.clicks) / B.clicks)*100 as clicks_growth
  14. from
  15. ((select query, clicks, ctr, impressions, weeknum
  16. from hhh.hhh_weekly_keywords
  17. where weeknum=26) as A
  18. inner join (select query, clicks, ctr, impressions, weeknum from hhh.hhh_weekly_keywords where weeknum=25) as B
  19. on A.query=B.query)
  20. order by
  21. clicks_growth desc
  22. limit 20;