Updated 2023-09-14
    with tb1 as (select
    distinct BUYER_ADDRESS as u1,
    min(BLOCK_TIMESTAMP) as x1
    from ethereum.core.ez_nft_sales
    where price_usd is not NULL
    and CREATOR_FEE_USD is not null
    and PROJECT_NAME='art blocks'
    group by 1 ),

    tb2 as (SELECT
    distinct SELLER_ADDRESS as u2,
    min(BLOCK_TIMESTAMP) as x2
    from ethereum.core.ez_nft_sales
    where price_usd is not NULL
    and CREATOR_FEE_USD is not null
    and PROJECT_NAME='art blocks'
    and SELLER_ADDRESS in (select u1 from tb1)
    group by 1) ,

    tb3 as (select
    tb1.u1 as purchaser,
    avg(DATEDIFF(day,x1, x2 )) as time_between
    from tb1
    join tb2 on tb1.u1=tb2.u2
    group by 1)
    select
    case when time_between<1 then 'whitin 24 Hours'
    when time_between>=1 and time_between<7 then '1 Day to 1 week'
    when time_between>=7 and time_between<30 then '1 week to 1 month'
    when time_between>=30 then 'Over 1 month'
    end as buckets,
    count(distinct purchaser) as count_users
    from tb3
    group by 1