Hadisehopen eth 7
    Updated 2022-12-09
    with purchaset as (
    select buyer_address,
    'Valhalla' as nft,
    nft_address,
    tokenid,
    min (block_timestamp::date) as buying_date
    from ethereum.core.ez_nft_sales t1
    where NFT_ADDRESS=lower('0x231d3559aa848Bf10366fB9868590F01d34bF240')
    and price_usd > 0
    group by 1,2,3,4),

    salet as (
    select seller_address,
    'Valhalla' as nft,
    t1.nft_address,
    t1.tokenid,
    min (block_timestamp::date) as selling_date
    from ethereum.core.ez_nft_sales t1
    where NFT_ADDRESS=lower('0x231d3559aa848Bf10366fB9868590F01d34bF240')
    and price_usd > 0
    and seller_address in (select buyer_address from purchaset)
    and tokenid in (select tokenid from purchaset)
    and nft_address in (select nft_address from purchaset)
    group by 1,2,3,4),

    maintable as (
    select datediff (day,buying_date, selling_date) as num_of_holding_days,
    buyer_address,
    seller_address,
    t1.nft,
    t1.nft_address,
    t1.tokenid
    from salet t1 join purchaset t2 on t1.seller_address = t2.buyer_address and t1.nft_address = t2.nft_address and t1.tokenid = t2.tokenid
    where num_of_holding_days >= 0)

    select nft,
    Run a query to Download Data