Query editor
WITH pndc_mined AS (SELECTc."to" AS address,SUM(c."value" / 1e18) AS total_pndc_minedFROM ethereum.transactions AS aINNER JOIN ethereum.traces_decoded AS bON a.hash = b.tx_hashINNER JOIN erc20_ethereum.evt_Transfer AS cON a.hash = c.evt_tx_hashWHEREa.to = 0xe7f01261EF9792095E22aBBF7F6f7B881D423C28 /* Pond Claims contract */AND a.success = TRUEAND b.function_name = 'claim'AND c.contract_address = 0x423f4e6138E475D85CF7Ea071AC92097Ed631eea /* $PNDC */GROUP BYc."to"),pndc_sold AS (SELECTd.tx_from AS address,SUM(d.token_sold_amount) AS total_pndc_soldFROM dex.trades AS dWHEREd.blockchain = 'ethereum'AND d.token_sold_address = 0x423f4e6138E475D85CF7Ea071AC92097Ed631eea /* $PNDC */GROUP BYd.tx_from),pndc_counts AS (SELECTm.address AS address,m.total_pndc_minedFROM pndc_mined AS mLEFT JOIN pndc_sold AS sON m.address = s.addressWHERE s.address IS NULL),ranked_pndc_counts AS (SELECTaddress,total_pndc_mined,RANK() OVER (ORDER BY total_pndc_mined DESC) AS mining_rankFROM pndc_counts)SELECTrpc.address,rpc.total_pndc_mined,rpc.mining_rankFROM ranked_pndc_counts AS rpc;