0xaimanAmount of User using Shuttle Before Starting to Use Wormhole
    Updated 2022-01-19
    select Days_before_using_wormhole,count(s1) as n_user, avg(day_range)

    from(select s1, day_range,case when day_range<100 then'less than 100 Days' else 'more than 100 days' end as Days_before_using_wormhole
    from (
    with wt as ( select date_trunc('day',tmin) as date1, s1
    from (select event_attributes:recipient as s1, min(block_timestamp) as tmin
    from terra.msg_events
    where event_type='wasm'
    and event_attributes:contract_address='terra10nmmwe8r3g99a9newtqa7a75xfgs2e8z87r2sf' and
    event_attributes:recipient is not null
    group by 1
    )
    group by 1,2),

    st as (select date_trunc('day',tmin2) as date2, s2
    from (select msg_value:from_address as s2, min(block_timestamp) as tmin2
    from terra.msgs
    where msg_value:to_address='terra1g6llg3zed35nd3mh9zx6n64tfw3z67w2c48tn2'
    group by 1 order by 1)
    group by 1,2)


    select s1, date1 as wormhole_use_date,date2 as shuttle_use_date, DATEDIFF(day, shuttle_use_date, wormhole_use_date) as day_range
    from wt
    inner join st on wt.s1=st.s2
    )
    where day_range>0

    )
    group by 1 order by 1
    Run a query to Download Data