Moe tp.sht hold duration- playtype
    Updated 2022-10-13

    with buy as (select
    block_timestamp,s.nft_id,buyer,seller,play_type from
    flow.core.fact_nft_sales s
    join flow.core.dim_topshot_metadata m on s.NFT_ID = m.NFT_ID
    where
    s.NFT_COLLECTION = 'A.0b2a3299cc857e29.TopShot'
    and currency = 'A.ead892083b3e2c6c.DapperUtilityCoin' and TX_SUCCEEDED = 'TRUE'
    )
    ,sell as (select
    block_timestamp,s.nft_id,buyer,seller,play_type from
    flow.core.fact_nft_sales s
    join flow.core.dim_topshot_metadata m on s.NFT_ID = m.NFT_ID
    where
    s.NFT_COLLECTION = 'A.0b2a3299cc857e29.TopShot'
    and currency = 'A.ead892083b3e2c6c.DapperUtilityCoin' and TX_SUCCEEDED = 'TRUE'
    )

    ,base as (
    select
    b.*,s.BLOCK_TIMESTAMP as sBLOCK_TIMESTAMP
    from
    buy b join sell s on b.buyer = s.seller
    and s.BLOCK_TIMESTAMP > b.BLOCK_TIMESTAMP
    ),
    fin as (select
    NFT_ID,buyer ,play_type,BLOCK_TIMESTAMP as purchase_time,
    sBLOCK_TIMESTAMP as selling_time,datediff(day,purchase_time,selling_time) as duration_hours
    from base)

    select
    play_type ,
    avg(duration_hours) as avg_hold_days,
    row_number()over(order by avg_hold_days desc) as n
    from fin
    Run a query to Download Data