adambalamotor22
    Updated 2022-09-06
    with buytable1 as (
    select buyer_address, tx_hash, tokenid, price_usd,price
    FROM optimism.core.ez_nft_sales
    WHERE platform_name = 'quixotic' and EVENT_TYPE = 'sale' and CURRENCY_SYMBOL = 'ETH'
    and lower(NFT_ADDRESS)=lower('0x5c9D55b78FEBCC2061715BA4f57EcF8EA2711F2c')
    and price_usd > 0 and price > 0),

    selltable1 as (
    select seller_address, tx_hash, tokenid, price_usd,price
    FROM optimism.core.ez_nft_sales
    WHERE platform_name = 'quixotic' and EVENT_TYPE = 'sale' and CURRENCY_SYMBOL = 'ETH'
    and lower(NFT_ADDRESS)=lower('0x5c9D55b78FEBCC2061715BA4f57EcF8EA2711F2c')
    and price_usd > 0 and price > 0)

    select buyer_address,
    t1.tokenid,
    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
    group by 1,2
    order by 4 DESC
    limit 10
    Run a query to Download Data