jackguyens 3
    Updated 2022-09-14
    WITH tab1 as (
    SELECT
    tx_hash as tx_hash2,
    block_timestamp as bt,
    CASE WHEN event_inputs:name IS NOT NULL THEN event_inputs:name END as ens_name,
    CASE WHEN event_inputs:cost IS NOT NULL THEN event_inputs:cost / power(10,18) END as price_eth
    FROM ethereum.core.fact_event_logs
    WHERE origin_function_signature LIKE '0xf7a16963'
    AND event_name like 'NameRegistered'
    AND contract_name LIKE 'ETHRegistrarController'
    ), tab2 as (
    SELECT
    tx_hash as tx_hash3,
    event_inputs:id as nft_id
    FROM ethereum.core.fact_event_logs
    WHERE origin_function_signature LIKE '0xf7a16963'
    AND event_name like 'NameRegistered'
    AND contract_name LIKE 'BaseRegistrarImplementation'
    ), tab3 as (
    SELECT *
    -- date_trunc('day', block_timestamp),
    -- CASE WHEN length(ENS_NAME) <= 3 THEN 'Less than 3 character'
    -- WHEN length(ENS_NAME) <= 5 THEN 'Between 3 and 5 character'
    -- WHEN length(ENS_NAME) <= 8 THEN 'Between 5 and 8 character'
    -- ELSE 'Over 8 character' END as digit_group,
    -- count(DISTINCT tx_hash) as events,
    -- sum(price_eth) as price_volume
    from tab1 left outer join tab2
    on tx_hash3 = tx_hash2
    )

    SELECT
    date_trunc('week', block_timestamp) as day,
    length(ENS_NAME) as digit_group,
    count(*) as sales,
    sum(price) as eth_volume,
    Run a query to Download Data