Query editor
WITH addresses AS (SELECT useraddress,whitelistallocationethFROM dune.halix.dataset_cypher_allocation_addresses),buys AS(SELECT l.block_time,COALESCE(CAST(e.name AS VARCHAR), CAST(l.tx_from AS VARCHAR)) AS buyer,t.value / 1e18 AS eth_amount,(VARBINARY_TO_UINT256(BYTEARRAY_SUBSTRING(l.data, 33, 32)) /1e18) AS tokens_boughtFROM ethereum.logs lLEFT JOIN ethereum.transactions t ON l.tx_hash = t.hash AND successLEFT JOIN labels.ens e ON e.blockchain = 'ethereum' AND l.tx_from = e.addressWHERE 1=1AND l.contract_address = 0x3CD955a77b8842Fa5e7e1765E718905c04381AB7AND l.topic0 = 0x6faf93231a456e552dbc9961f58d9713ee4f2e69d15f1975b050ef0911053a7b),buyers AS (SELECT buyer,SUM(eth_amount) AS eth_paid,SUM(tokens_bought) AS tokens_bought,COUNT(eth_amount) AS times_boughtFROM buysGROUP BY 1ORDER BY eth_paid DESC)SELECT *,(tokens_bought / SUM(tokens_bought) OVER ()) AS pct_total-- ((SELECT COUNT * FROM buyers) / (SELECT COUNT * FROM addresses)) AS pct_boughtFROM buyers