adambalaDOODLES128
    Updated 2023-06-29
    with buytable1 as (
    select (BLOCK_TIMESTAMP) AS MINT_DATE ,BUYER_address, tx_hash, tokenid, price_usd,price
    FROM ethereum.core.ez_nft_sales
    WHERE EVENT_TYPE = 'sale' and CURRENCY_SYMBOL = 'ETH'
    and lower(NFT_ADDRESS)=lower('0x8a90cab2b38dba80c64b7734e58ee1db38b8992e')
    and price_usd > 0 and price > 0 ),

    selltable1 as (
    select (BLOCK_TIMESTAMP) AS DATE ,seller_address, tx_hash, tokenid, price_usd,price
    FROM ethereum.core.ez_nft_sales
    WHERE EVENT_TYPE = 'sale' and CURRENCY_SYMBOL = 'ETH'
    and lower(NFT_ADDRESS)=lower('0x8a90cab2b38dba80c64b7734e58ee1db38b8992e')
    and price_usd > 0 and price > 0 )

    select case
    when "hold time " <1 then '< 1 day '
    when "hold time " between 1 and 5 then ' 1 - 5 day '
    when "hold time " between 5 and 10 then ' 5 - 10 day '
    when "hold time " between 10 and 20 then ' 10 - 20 day '
    when "hold time " between 20 and 50 then ' 20 - 50 day '
    when "hold time " between 50 and 100 then ' 50 - 100 day '
    when "hold time " between 100 and 200 then ' 100 - 200 day '
    when "hold time " between 200 and 400 then ' 200 - 400 day '
    when "hold time " > 400 then '> 400 day '
    end as "name"
    ,count(distinct trader) as "value"
    from (select
    'https://www.nftscan.com/' || BUYER_address as trader,
    'https://www.nftscan.com/0x8a90cab2b38dba80c64b7734e58ee1db38b8992e/' ||t1.tokenid as "token id",
    datediff('day',MINT_date,date) as "hold time "
    --T2.price || ' - '||T1.price || ' = ' as "Sale PRICE - bought PRICE (ETH)" ,
    --sum (t2.price_usd - t1.price_usd) as USD_Profit
    --sum (t2.price - t1.price) as ETH_Profit
    from buytable1 t1 join selltable1 t2 on BUYER_address = seller_address and t1.tokenid = t2.tokenid
    WHERE MINT_date < DATE
    order by 3 desc
    Run a query to Download Data