Query editor
withunited_win as (selectbettor,bet_time,usd_amount as amount,odds AS win_odds,usd_payoutAmount as payoutAmount,bet_idfrom dune.azuro.result_ordinars_combos_resolvedwhere GGR < 0),-- win_betsunited_bets as (selectbet_time,bettor,usd_amount as amount,usd_payoutAmount as payoutAmount,usd_GGR as GGR,bet_idfrom dune.azuro.result_ordinars_combos_resolved -- all_bets),bettors as (selectbettor,sum(amount) as total_bets_amount,sum(payoutAmount) as total_payouts,sum(GGR) as total_GGR,max(amount) as max_bet,min(amount) as min_bet,avg(amount) as avg_bet,count(distinct bet_id) as bets_countfromunited_betsgroup bybettor),winners as (selectbettor,count(distinct bet_id) as win_bets,sum(amount) as amount,max(amount) as max_win_bet,max(-payoutAmount) as max_payout,max(win_odds) as max_win_oddsfromunited_wingroup bybettor),stats as (selectb.bettor,b.bets_count,b.total_bets_amount,b.total_payouts,