RienSQL
TASK #170 · Medium · Entain

Average Bet and Total Wins per Active Player

Your brief
For every active player (customers.active = true) output customer_name, avg_bet — that player's average bet size (rounded to two decimals) — and total_wins — their total win amount. If the player has no wins yet, return 0, not NULL.

Beware: a naive JOIN bets × wins on customer_id yields a Cartesian product per player and corrupts both aggregations. Compute averages and sums separately, then join the already-aggregated results.

Sort by customer_name.
Expected columnscustomer_name avg_bet total_winsEntain / Bwin
SQL editor
SQLite
Ctrl / ⌘ + ↵
Result

Write a query and run it to see the results.

Schema
customerscustomer_id, name, country, active
gamesgame_id, name, game_category
betsbet_id, customer_id, game_id, bet_date, bet_amount, betting_type
winswin_id, customer_id, win_date, win_amount