B09Fidenza 3_1
    Updated 2023-11-18
    WITH ResaleCounts AS (
    SELECT TOKENID, COUNT(*) AS ResaleCount
    FROM ethereum.nft.ez_nft_sales
    WHERE TOKENID IN (
    SELECT TOKENID
    FROM ethereum.nft.dim_nft_collection_metadata
    WHERE NFT_ADDRESS = '0xa7d8d9ef8d8ce8992df33d8b8cf4aebabd5bd270'
    AND TOKENID_NAME LIKE 'Fidenza%'
    )
    GROUP BY TOKENID
    )

    --3. For the Fidenza project, find the art piece (nft) that has been resold the most
    -- and list the token# and average holding time. Include a link to the item on opensea
    -- in the comments on the dashboard. If possible, add the NFT image to the dashboard.
    -- See if you can figure out why that particular Fidenza is attracting so much attention
    -- and write about it on the dashboard.
    SELECT
    rc.TOKENID,
    AVG(DATEDIFF('DAY', es_prev.BLOCK_TIMESTAMP, es.BLOCK_TIMESTAMP)) AS AVG_Holding_Time,
    CONCAT('https://opensea.io/assets/0xa7d8d9ef8d8ce8992df33d8b8cf4aebabd5bd270/', rc.TOKENID) AS Opensea_Link,
    rc.ResaleCount
    FROM
    ethereum.nft.ez_nft_sales es
    JOIN
    ethereum.nft.ez_nft_sales es_prev
    ON
    es.TOKENID = es_prev.TOKENID
    AND es.BLOCK_TIMESTAMP > es_prev.BLOCK_TIMESTAMP
    AND es_prev.BLOCK_TIMESTAMP = (
    SELECT MAX(BLOCK_TIMESTAMP)
    FROM ethereum.nft.ez_nft_sales
    WHERE TOKENID = es.TOKENID
    AND BLOCK_TIMESTAMP < es.BLOCK_TIMESTAMP
    )
    JOIN
    Run a query to Download Data