Query editor
/*Combined a few of my token stats queries into this queryAdded the selected_token CTE to keep token specific data all in one place.Removed Trader Joe LP price lookup as most tokens (or newer tokens) are notguaranteed to have lfj LP.This doesn't do everrything my previous queries did, but it's a good middle groundthat simplifies spinning up a new token stats dash.*/WITHselected_token AS (SELECT0xcd94a87696FAC69Edae3a70fE5725307Ae1c43f6 AS contract_address,'BLACK' AS symbol,18 AS decimals,'avalanche_c' as blockchain),daily_token_price_from_dex AS (SELECTdate(block_time) AS utc_date,approx_percentile(amount_usd / (CASEWHENtoken_bought_address = (select contract_address from selected_token)THEN token_bought_amountELSE token_sold_amountEND),0.5) AS price_usdFROMdex.tradesWHEREblockchain = (select blockchain from selected_token)AND (token_bought_address = (select contract_address from selected_token)OR token_sold_address = (select contract_address from selected_token))AND amount_usd > 0AND ((token_bought_address = (select contract_address from selected_token)AND token_bought_amount > 0)OR (token_sold_address = (select contract_address from selected_token)AND token_sold_amount > 0))GROUP BY1