adambalaLongest sale's period-- Max Holding Time in day
    Updated 2023-05-14
    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('0x960b7a6bcd451c9968473f7bbfd9be826efd549a')
    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('0x960b7a6bcd451c9968473f7bbfd9be826efd549a')
    and price_usd > 0 and price > 0 )

    select
    datediff('day',MINT_date,date) as "hold time " ,t1.tokenid ,
    'https://www.nftscan.com/' || BUYER_address as trader,
    'https://www.nftscan.com/0x960b7a6bcd451c9968473f7bbfd9be826efd549a/' ||t1.tokenid as "token id"
    --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 1 desc
    limit 10
    Run a query to Download Data