Query editor
WITHusers as(select distinct trader_id from query_4216057),base AS (SELECTDATE_TRUNC('day', trades.block_time) AS block_date,DATE_TRUNC('week', trades.block_time) AS block_week,DATE_TRUNC('month', trades.block_time) AS block_month,amount_usd,CASEWHEN trades.token_sold_mint_address = 'So11111111111111111111111111111111111111112' THEN 'Buy'ELSE 'Sell'END AS type,trades.trader_id AS userAddress,trades.tx_id AS tx_hash,trades.token_bought_symbol as tokenFROMdex_solana.trades tradesinner joinusers on trades.trader_id = users.trader_idwhere token_bought_symbol not IN ('JitoSOL','mSOL' , 'stSOL' ,'jito' , 'bSOL' , 'jSOL' , 'scnSOL' ,'mrgnLST','edgeSOL','pwrSOL' ,'superSOL' ,'jucySOL' ,'bonkSOL' ,'driftSOL' ,'compassSOL' ,'heliusSOL' ,'picoSOL' , 'jupSOL','')OR token_sold_symbol not IN ('JitoSOL','mSOL' , 'stSOL' ,'jito' , 'bSOL' , 'jSOL' , 'scnSOL' ,'mrgnLST','edgeSOL','pwrSOL' ,'superSOL' ,'jucySOL' ,'bonkSOL' ,'driftSOL' ,'compassSOL' ,'heliusSOL' ,'picoSOL' , 'jupSOL','')and token_pair not in ('USDC-SOL', 'USDT-SOL', 'USDT-USDC', 'WETH-USDC','WETH-SOL', 'WETH-USDT')),metrics AS (SELECTuserAddress,token,SUM(CASE WHEN type = 'Sell' THEN amount_usd ELSE 0 END) - SUM(CASE WHEN type = 'Buy' THEN amount_usd ELSE 0 END) AS netPnLUSD,SUM(CASE WHEN type = 'Sell' THEN amount_usd ELSE 0 END)/ SUM(CASE WHEN type = 'Buy' THEN amount_usd ELSE 0 END) As win_multipleFROMbasewhere token != 'SOL'GROUP BYuserAddress,token)selectuserAddress,count(token) as tokens_traded,count(case when netPnLUSD > 0 then 1 else 0 end) / count(token) as winrate,avg(win_multiple) as avg_win_multiple,count (case when win_multiple >= 10 and win_multiple <50 then 1 else 0 end) as x10_wins,count (case when win_multiple >= 50 and win_multiple <100 then 1 else 0 end) as x50_wins,count (case when win_multiple >= 100 then 1 else 0 end) as x100_winsfrom metricsgroup by 1