Updated 2023-11-22
    with t1 as (select
    SUBSTRING(post_text, CHARINDEX('#', post_text),CHARINDEX(' ', post_text)) as tag,
    upper(SUBSTRING(tag, CHARINDEX('#', tag)+1)) as hashtag,
    tx_hash
    from near.social.fact_posts
    WHERE BLOCK_TIMESTAMP >= CURRENT_DATE - {{Time_period_days}}
    and post_text ilike '#%'
    and post_text not ilike '##%'
    and tag not in ('##','###', '# ')
    )

    select
    distinct hashtag,
    count(tx_hash) as "Posts"
    from t1
    where hashtag!=''
    group by 1 having hashtag is not null
    order by 2 desc
    limit 10
    Run a query to Download Data