MLDZMNsmartnft7
    Updated 2023-03-27
    with tb5 as (
    SELECT
    trunc(timestamp,'day') as day,
    avg(price_usd) as price_token
    from near.core.fact_prices where symbol='wNEAR'
    group by 1
    ),

    tot AS (
    SELECT
    block_timestamp,
    tx_hash,
    receiver_id,
    logs,
    try_parse_json(value) as parse_logs,
    parse_logs:type as type,
    parse_logs:params:buyer_id as buyer_id,
    parse_logs:params:owner_id as owner_id,
    parse_logs:params:is_offer as is_offer,
    parse_logs:params:is_auction as is_auction,
    parse_logs:params:nft_contract_id as nft_contract_id,
    parse_logs:params:token_id as token_id,
    parse_logs:params:ft_token_id as ft_token_id,
    parse_logs:params:price/pow(10,24) as near,
    regexp_substr(status_value, 'Success') as reg_success
    FROM near.core.fact_receipts,
    table(flatten(input=>logs))
    WHERE 1=1
    AND type = 'resolve_purchase'
    AND reg_success IS NOT NULL
    and BLOCK_TIMESTAMP>='2023-01-01'
    ),
    buy as (
    select
    buyer_id as buyer,
    Run a query to Download Data