Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. create materialized view uclahiv.public.tweetbursts as
  2. SELECT t.tdate, t.htname, t.count, t."time"
  3. FROM dblink('myconn' :: text, '(with c as (SELECT date(twitterstatus.created_at) AS date,
  4. (jsonb_array_elements(
  5. ((twitterstatus.entities -> ''entities'' :: text) -> ''hashtags'' :: text)) ->>''text'' :: text) AS hashtags,
  6. count(id) as total,
  7. date_part(''hour'', created_at) as hour
  8. FROM twitterstatus
  9. GROUP BY date, hour, hashtags
  10. having count(id) > 20
  11.  
  12. order by hashtags, date, hour)
  13. SELECT x.date, hashtags, total, hour
  14. from c As x
  15. where exists(select 1
  16. from c AS y
  17. where y.date = x.date + 1
  18. AND y.hashtags = x.hashtags));
  19. ' :: text) t (tdate date, htname text, count integer, "time" integer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement