Query editor
WITH getDailyLinkPrice as (SELECT date,avg_priceFROM query_1996848WHERE symbol = 'LINK'),getDailyBets as (SELECT blockchain,symbol,distinct_total_user,total_games_played,total_bet_volume_usd,total_bet_volume,ggr_price_on_txn,ggr * latest_price as ggr_current_price_usd,ggr,CASE WHEN asset_name IS NOT NULL THEN '<a target="_blank" href="https://app.betswirl.com/analytics?c='|| CAST(q.chain_id AS VARCHAR)|| '&token='|| CAST(asset_name as VARCHAR)|| '">'|| ' 🍥</a>' END AS pol_link-- CASE WHEN blockchain = 'Polygon' THEN '<a target="_blank" href="https://polygonscan.com/address/'-- WHEN blockchain = 'Arbitrum' THEN '<a target="_blank" href="https://arbiscan.io/address/'-- WHEN blockchain = 'BNB Chain' THEN '<a target="_blank" href="https://bscscan.com/address/'-- WHEN blockchain = 'Avalanche' THEN '<a target="_blank" href="https://snowtrace.io/address/' END-- || CAST(address AS VARCHAR)-- || '">'-- || ' 🍥</a>' AS pol_linkFROM (SELECT blockchain,symbol,COUNT(DISTINCT user) FILTER (WHERE amount > 0) as distinct_total_user,COUNT(DISTINCT evt_tx_hash) FILTER (WHERE amount >0) as total_games_played,COALESCE(SUM(amount_usd),0) as total_bet_volume_usd,COALESCE(SUM(amount),0) as total_bet_volume,SUM(amount_usd - payout_amount_usd) as ggr_price_on_txn,SUM(amount - payout_amount) as ggrFROM query_2611982 -- player vs house games only, no sports/pvp gamesLEFT JOIN getDailyLinkPrice ON date = date_trunc('day',evt_block_time)WHERE CASE WHEN '{{chain}}' = 'All' THEN 1 = 1 ELSE blockchain = '{{chain}}' ENDAND CASE WHEN '{{token}}' = 'All' THEN 1 = 1 ELSE symbol = '{{token}}' ENDAND evt_block_time BETWEEN CAST('{{start date}}' AS TIMESTAMP) AND CAST('{{end date}}' AS TIMESTAMP)AND symbol NOT IN ('BUSD','MIMATIC','USDC','FLOKI')GROUP BY 1,2) xLEFT JOIN query_2611987 USING (symbol) -- get latest priceLEFT JOIN query_2507321 USING (blockchain)LEFT JOIN query_2612104 q USING (blockchain,symbol) -- get pol data),getDailyRevenue as (SELECT blockchain,symbol,SUM(bank_usd) as total_bank_revenue_usd,SUM(dividend_usd)as total_dividend_revenue_usd,SUM(partner_usd) as total_partner_revenue_usd,SUM(treasury_usd) as total_treasury_revenue_usd,SUM(team_usd) as total_team_revenue_usd,