Advertisement
Guest User

Untitled

a guest
May 26th, 2019
2,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. CREATE VIEW games AS
  2. SELECT hashtag, retweeted_id, quoted_id,
  3. CASE WHEN hashtag ~~* '%GrandTheftAutoV%' THEN 'GrandTheftAutoV'
  4. WHEN hashtag ~~* '%LeagueOfLegends%' THEN 'LeagueOfLegends'
  5. WHEN hashtag ~~* '%Fortnite%' THEN 'Fortnite'
  6. WHEN hashtag ~~* '%dota2%' THEN 'dota2'
  7. WHEN hashtag ~~* '%CSGO%' THEN 'CSGO'
  8. WHEN hashtag ~~* '%ApexLegends%' THEN 'ApexLegends'
  9. WHEN hashtag ~~* '%Hearthstone%' THEN 'Hearthstone'
  10. WHEN hashtag ~~* '%overwatch%' THEN 'overwatch'
  11. ELSE NULL END AS game,
  12. CASE WHEN quoted_id IS NOT NULL THEN True
  13. ELSE False END AS if_quoted,
  14. CASE WHEN retweeted_id IS NOT NULL THEN True
  15. ELSE False END AS if_retweeted
  16. FROM(
  17. SELECT *
  18. FROM base_tweets
  19. JOIN hashtags
  20. ON base_tweets.tweet_id = hashtags.tweet_id) AS base_hash
  21. LEFT JOIN retweeted_tweet
  22. ON base_hash.retweeted_tweet_id = retweeted_tweet.retweeted_id
  23. LEFT JOIN quoted_tweets
  24. ON base_hash.quoted_tweet_id = quoted_tweets.quoted_id;
  25.  
  26. SELECT *
  27. FROM games
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement