nitsTop 10 Most Profiting Addresses in the past n days
    Updated 2022-11-19
    with buyer as
    (SELECT buyer_address,tokenid as id , block_timestamp as purchase_time, price_usd as buy_price
    from
    ethereum.core.ez_nft_sales
    where (nft_address ilike '0x959e104e1a4db6317fa58f8295f586e1a978c297' or nft_address ilike '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d')),
    seller as
    (SELECT seller_address,tokenid , block_timestamp as sale_time , price_usd as sale_price
    from
    ethereum.core.ez_nft_sales
    where (nft_address ilike '0x959e104e1a4db6317fa58f8295f586e1a978c297' or nft_address ilike '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d'))


    SELECT buyer_address, net_profit from
    (SELECT *, sale_price- buy_price as net_profit from buyer
    inner join seller
    on seller_address = buyer_address and tokenid = id and purchase_time < sale_time)
    where date(sale_time) >= CURRENT_DATE - {{n}} and net_profit is not NULL
    order by net_profit desc
    LIMIT 10