Query editor
WITH leaderboard AS (SELECTCAST(json_extract_scalar(item, '$.player') AS varchar) AS player,CAST(json_extract_scalar(item, '$.games_played') AS bigint) AS games_played,CAST(json_extract_scalar(item, '$.wins') AS bigint) AS wins,CAST(json_extract_scalar(item, '$.losses') AS bigint) AS losses,CAST(json_extract_scalar(item, '$.win_rate') AS double precision) AS win_rate,CAST(json_extract_scalar(item, '$.win_loss_ratio') AS double precision) AS win_loss_ratio,CAST(json_extract_scalar(item, '$.score') AS double) AS scoreFROM UNNEST(CAST(json_extract(json_parse(http_get('https://tanksfun-indexer-production.up.railway.app/dune/metrics/leaderboard')),'$.rows') AS array(json))) AS t(item)),agg AS (SELECTCOUNT(*) AS total_players,AVG(games_played) AS avg_games_played,AVG(wins) AS avg_wins,AVG(losses) AS avg_losses,AVG(win_rate) AS avg_win_rate,AVG(win_loss_ratio) AS avg_win_loss_ratio,AVG(score) AS avg_scoreFROM leaderboard)SELECT 'avg games played' AS metric, avg_games_played as value FROM aggUNION ALLSELECT 'avg wins', avg_wins FROM aggUNION ALLSELECT 'avg losses', avg_losses FROM aggUNION ALLSELECT 'avg score = ( games_played / wins ) × games_played', avg_score FROM agg