Download example_queries.sql from ghostcitadel/casino: direct link, hf CLI and curl.
- Browser
- Download file 4.03 kB
-
https://huggingface.co/datasets/ghostcitadel/casino/resolve/main/example_queries.sql
- Command line
-
hf download hf://datasets/ghostcitadel/casino/example_queries.sql
-
curl -L -o example_queries.sql https://huggingface.co/datasets/ghostcitadel/casino/resolve/main/example_queries.sql
4.03 kB
| -- Run against askersund_operational.duckdb. | |
| -- Monetary values are integer ore; negative net_result_ore is a player loss. | |
| -- 1. Largest daily player losses and same-day deposit intensity. | |
| SELECT player_id, day, deposit_count, deposit_ore, session_count, | |
| stake_ore, gross_payout_ore, net_result_ore, | |
| round(loss_to_previous_28d_ratio, 2) AS loss_spike_ratio | |
| FROM player_daily | |
| WHERE net_result_ore < 0 | |
| ORDER BY net_result_ore | |
| LIMIT 25; | |
| -- 2. Deposit spikes relative to the preceding 28 days (current day excluded). | |
| SELECT player_id, day, deposit_count, deposit_ore, | |
| round(deposit_to_previous_28d_ratio, 2) AS deposit_spike_ratio, | |
| cumulative_deposit_ore | |
| FROM player_daily | |
| WHERE deposit_ore > 0 AND deposit_to_previous_28d_ratio > 3 | |
| ORDER BY deposit_to_previous_28d_ratio DESC | |
| LIMIT 25; | |
| -- 3. Player financial position at the end of the fixture. | |
| WITH last_day AS ( | |
| SELECT player_id, max(day_index) AS day_index FROM player_daily GROUP BY player_id | |
| ) | |
| SELECT d.player_id, p.full_name, d.cumulative_deposit_ore, | |
| d.cumulative_stake_ore, d.cumulative_net_result_ore, | |
| d.real_balance_end_ore, d.withdrawal_hold_end_ore | |
| FROM player_daily d | |
| JOIN last_day l USING (player_id, day_index) | |
| JOIN players p USING (player_id) | |
| ORDER BY d.cumulative_net_result_ore; | |
| -- 4. Withdrawals with lifetime settled turnover below 2x the requested amount. | |
| SELECT w.player_id, w.withdrawal_id, w.requested_at, w.requested_amount_ore, | |
| w.status, coalesce(sum(r.stake_ore), 0) AS lifetime_stake_ore, | |
| round(coalesce(sum(r.stake_ore), 0) / w.requested_amount_ore, 3) AS turnover_ratio | |
| FROM withdrawals w | |
| LEFT JOIN game_rounds r | |
| ON w.player_id = r.player_id AND r.status = 'settled' | |
| GROUP BY w.player_id, w.withdrawal_id, w.requested_at, | |
| w.requested_amount_ore, w.status | |
| HAVING coalesce(sum(r.stake_ore), 0) < 2 * w.requested_amount_ore | |
| ORDER BY turnover_ratio, w.requested_amount_ore DESC; | |
| -- 5. Open KYC-related withdrawal exposure. | |
| SELECT player_id, withdrawal_id, requested_at, requested_amount_ore, status | |
| FROM withdrawals | |
| WHERE status = 'under_review' | |
| ORDER BY requested_at; | |
| -- 6. Repeated-deposit and high-loss days for RG workflow review. | |
| SELECT player_id, day, deposit_count, deposit_ore, net_result_ore, | |
| rg_signal_count, session_count, round_count | |
| FROM player_daily | |
| WHERE deposit_count >= 3 OR rg_signal_count > 0 | |
| ORDER BY day, player_id; | |
| -- 7. Reconcile every financial transaction: all results must be zero. | |
| SELECT t.tx_id, t.tx_type, sum(p.amount_ore) AS imbalance_ore | |
| FROM ledger_transactions t | |
| JOIN ledger_postings p USING (tx_id) | |
| GROUP BY t.tx_id, t.tx_type | |
| HAVING sum(p.amount_ore) <> 0; | |
| -- 8. Empirical gross RTP by game, excluding aborted rounds. | |
| SELECT game_code, count(*) AS settled_rounds, sum(stake_ore) AS stake_ore, | |
| sum(gross_payout_ore) AS payout_ore, | |
| sum(gross_payout_ore) / sum(stake_ore) AS empirical_rtp | |
| FROM game_rounds | |
| WHERE status = 'settled' | |
| GROUP BY game_code; | |
| -- 9. Split-payment components. | |
| SELECT e.event_id, | |
| json_extract_string(e.attributes_json, '$.withdrawal_id') AS withdrawal_id, | |
| json_extract_string(e.attributes_json, '$.payment_order_id') AS payment_order_id, | |
| json_extract(e.attributes_json, '$.amount_ore') AS amount_ore, | |
| json_extract(e.attributes_json, '$.component_sequence') AS component_sequence, | |
| json_extract(e.attributes_json, '$.component_count') AS component_count | |
| FROM events e | |
| WHERE event_type = 'withdrawal.paid' | |
| AND json_extract(e.attributes_json, '$.component_count') > 1 | |
| ORDER BY withdrawal_id, component_sequence; | |
| -- 10. Point-in-time ML join. Ground truth is joined explicitly, never stored operationally. | |
| -- Attach ml/labels.parquet before running, for example: | |
| -- CREATE VIEW ml_labels AS SELECT * FROM read_parquet('ml/labels.parquet'); | |
| SELECT d.*, l.rg_onset_next_30d, l.aml_scheme_start_next_30d, | |
| l.churn_start_next_30d, l.churn_label_observed | |
| FROM player_daily d | |
| JOIN ml_labels l ON d.player_id = l.player_id AND d.day = l.cutoff_day | |
| WHERE d.day_index >= 30; | |