HosseinUntitled Query
    Updated 2022-11-15
    with
    near as (
    select date_trunc('day', timestamp)::date as day,
    symbol,
    avg (price_usd) as usdprice
    from near.core.fact_prices
    where timestamp >= '{{ start_date }}'
    group by day, symbol
    ),

    flow as (
    select date_trunc('day', timestamp)::date as day,
    token_contract,
    avg (price_usd) as usdprice
    from flow.core.fact_prices
    where timestamp >= '{{ start_date }}'
    group by token_contract, day
    ),

    osmosis as (
    select date_trunc('day', recorded_at)::date as day,
    symbol,
    avg (price) as osmo_usd
    from osmosis.core.dim_prices
    where day >= '{{ start_date }}'
    group by day, symbol
    ),

    maintable as (
    select 'NEAR' as chain,
    date_trunc(day,block_timestamp) as date,
    case when date >= '2022-11-07' then 'After Collapse'
    else 'Before Collapse' end as timespan,
    count (distinct tx_hash) as TX_Count,
    count (distinct trader) as Users_Count,
    sum (amount_in*usdprice) as Swap_Volume,
    Run a query to Download Data