Query editor
WITH erc_token_info AS (SELECT * FROM tokens.erc20WHERE contract_address = 0x046eee2cc3188071c02bfc1745a6b17c656e3f3d -- RLBAND blockchain = 'ethereum'),top_holder_balance AS (SELECT user_address,balance_amountFROM query_2761776ORDER BY balance_amount DESCLIMIT 1000),top_holder_transfer_inflow AS (SELECT h.user_address,COUNT(DISTINCT t.evt_tx_hash) AS in_transaction_count,COUNT(DISTINCT t."from") AS in_user_count,SUM(CAST(t.value AS decimal(38, 0)) / POWER(10, erc.decimals)) AS in_amountFROM erc20_ethereum.evt_Transfer tINNER JOIN top_holder_balance h ON t."to" = h.user_addressINNER JOIN erc_token_info erc ON TRUEWHERE t.contract_address = 0x046eee2cc3188071c02bfc1745a6b17c656e3f3d -- RLBAND t.evt_block_time >= DATE('2023-06-28')GROUP BY 1),top_holder_transfer_outflow AS (SELECT h.user_address,COUNT(DISTINCT t.evt_tx_hash) AS out_transaction_count,COUNT(DISTINCT t."from") AS out_user_count,SUM(CAST(t.value AS decimal(38, 0)) / POWER(10, erc.decimals)) AS out_amountFROM erc20_ethereum.evt_Transfer tINNER JOIN top_holder_balance h ON t."from" = h.user_addressINNER JOIN erc_token_info erc ON TRUEWHERE t.contract_address = 0x046eee2cc3188071c02bfc1745a6b17c656e3f3d -- RLBAND t.evt_block_time >= DATE('2023-06-28')GROUP BY 1),-- Fetching token prices for the RLB tokentoken_prices AS (SELECTDATE_TRUNC('day', hour) AS date,AVG(median_price) AS priceFROM dex.pricesWHERE contract_address = 0x046eee2cc3188071c02bfc1745a6b17c656e3f3d -- RLBGROUP BY 1),-- Fetching the most recent price (current market price) for RLBcurrent_rlb_price AS (SELECTAVG(median_price) AS current_priceFROM dex.pricesWHERE contract_address = 0x046eee2cc3188071c02bfc1745a6b17c656e3f3d -- RLBGROUP BY DATE_TRUNC('hour', hour) -- Correcting to group by hourORDER BY DATE_TRUNC('hour', hour) DESCLIMIT 1),