Skip to content

Instantly share code, notes, and snippets.

@veeve
Last active October 20, 2023 19:41
Show Gist options
  • Save veeve/486d0f2a15de5fcb8d6ef3960ced9f38 to your computer and use it in GitHub Desktop.
Save veeve/486d0f2a15de5fcb8d6ef3960ced9f38 to your computer and use it in GitHub Desktop.
tweets-sql
with tweets as (
select
t.user.name,
t.text,
upper(sym.text) as ticker
from
Demo.twitter_live as t,
unnest(t.entities.symbols) as sym
where
t.entities.symbols [1] is not null
and t.created_at > current_timestamp() - DAYS(1)
)
select
tw.ticker,
tkr.Name as CompanyName,
tkr.Industry,
count(*) as tweet_count
from
tweets as tw
join Demo.tickers_alias as tkr on tkr.Symbol = tw.ticker
group by
tw.ticker,
tkr.Name,
tkr.Industry
order by
count(*) desc
limit
10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment