Natural language analytics
What text-to-SQL means for an online casino
Text-to-SQL translates a question in everyday language into a SQL query over structured data. In iGaming, the useful outcome is a business answer tied to the operator’s own metrics: revenue by brand, acquisition cohorts, bonus costs or player return activity.
The language model needs more than table names. “Revenue” might mean GGR, defined NGR or contribution. “Last week” needs a reporting timezone and a complete period. A semantic layer describes those definitions, relevant relationships and permitted analytical dimensions so the same question keeps the same meaning.
Natural language analytics is the wider experience: ask a question, read the result and follow up. Text2SQL and NL2SQL are other names for the query-generation step. Generating valid SQL is one part of producing a useful answer.
Business meaning
Agree the revenue formula, player population, reporting period and currency before reading a result.
Query logic
Select the right grain and relationships so joins and deductions do not change the measure.
A checkable answer
Keep the comparison, data completeness and supporting calculation beside the conclusion.
From question to evidence
The working process behind a reliable answer
Clarify the question
Resolve an ambiguous metric, brand, currency or date range. Ask a narrower question when the intended comparison is unclear.
Map the business definitions
Choose the documented measure, source grain, relevant dimensions and handling of late, voided or reversed records.
Generate and inspect the SQL
Check filters, joins, grouping and aggregation against those definitions. A successful database execution does not establish business correctness.
Apply the execution policy
A production design should enforce the approved data scope, permissions, query limits and handling of restricted fields outside the language model.
Reconcile the result
Compare with a trusted total, inspect missing data and retain the period and formula with the answer.
Follow the next question
Move from the total to a brand, source, player group or game category while keeping the same metric and comparison.
A worked query
Compare defined NGR by casino brand
Question: “Compare NGR by brand for the complete week from 26 October to 1 November 2026, in EUR.” This worked example assumes a prepared daily revenue view with one row per brand, reporting day and currency. The view has already applied the reporting timezone, transaction-status rules and currency policy.
For this example only, NGR = stakes − payouts − bonus cost − other agreed deductions. The two deduction fields are disjoint, and bonus cost has not already been deducted from stakes or payouts. Real reporting policies can differ; use the GGR and NGR definitions guide to agree the formula first.
SELECT
brand_id,
currency,
SUM(stakes - payouts) AS ggr,
SUM(stakes - payouts
- bonus_cost - other_deductions) AS ngr
FROM casino_daily_revenue
WHERE report_date >= '2026-10-26'
AND report_date < '2026-11-02'
AND currency = 'EUR'
GROUP BY brand_id, currency
ORDER BY ngr DESC;The half-open interval includes the seven reporting dates and excludes the next week. It does not independently prove that all expected source records arrived. The field names describe a sample data model, not a required AskData integration or a client database.
| Brand | Stakes / payouts | Deductions | GGR / defined NGR |
|---|---|---|---|
| Brand A | €100,000 / €94,000 | €800 bonus + €200 other | €6,000 / €5,000 |
| Brand B | €80,000 / €75,200 | €600 bonus + €200 other | €4,800 / €4,000 |
| Portfolio | €180,000 / €169,200 | €1,400 bonus + €400 other | €10,800 / €9,000 |
Before using the result
Check the meaning as well as the syntax
| Check | What can go wrong | Useful validation |
|---|---|---|
| Grain and joins | One game event is repeated when joined to several incentive records. | Aggregate each source to the agreed grain before joining; compare row counts and totals. |
| Metric definition | Bonuses are deducted twice or deposits are treated as gaming revenue. | Reconcile the formula with the metric register and source report. |
| Time and completeness | A partial current week is compared with a complete previous week. | Use complete reporting windows and inspect expected source coverage. |
| Currency and brand | Amounts from different currencies or reporting scopes are summed together. | Keep currency explicit and apply the documented conversion and brand mapping. |
| Permissions and execution | Generated SQL requests data or actions outside the agreed scope. | Enforce database permissions, allowed operations and resource limits at execution. |
| Follow-up questions | A narrower question silently changes the denominator or period. | Retain the previous definitions and state what changed in the comparison. |
Evaluate an AI analyst
Give the system questions with known answers
Build an evaluation set from representative operator questions and independently checked results. Include revenue by brand, source costs, same-age cohorts, incentive deductions and returning-player activity. Add ambiguous questions, missing data and requests outside the approved scope.
Review the returned values, population and explanation against the expected business meaning. Different SQL can produce the same correct result; syntactic similarity alone is a weak test. Equally, a query that runs successfully may use the wrong population. Keep a record of failures and repeat the evaluation when definitions or schemas change.
Assess the complete workflow: does the system clarify an uncertain question, preserve the metric on a follow-up and make an unexpected total investigable? Agree acceptance criteria for your own data instead of assuming a published accuracy figure transfers to another casino.
Bring the method into the business
Start with an operator question in AskData
AskData’s AI analyst gives the casino question a starting point. Analytics connects it with revenue, acquisition, retention, bonuses, games and providers; Insights brings relevant KPI changes into view.
Bring one recurring question, its existing source report and the definitions your team uses. The casino revenue investigation shows how an initial answer can lead to a narrower business review. Agree source access, data scope, responsibilities and validation during the implementation discussion.
Common questions
Text-to-SQL questions from casino teams
What does Text2SQL mean in iGaming?
Text2SQL is another spelling of text-to-SQL: turning a plain-language question into a SQL query over structured casino data. The useful output is a checked business answer, so the metric, brand, reporting period, currency and permitted data scope still need to be defined.
Is text-to-SQL the same as a general AI chatbot?
Text-to-SQL produces a query over structured data under defined business meaning. A general chat response can discuss an industry without calculating anything from your casino’s records. Check how a proposed implementation connects the question, data and result.
Can it replace the metric model?
The metric model supplies the definitions and relationships a useful query needs. Natural language makes those definitions easier to use; it does not remove the need to agree them.
Does a valid SQL query prove the answer is correct?
No. The query may still use a wrong join, period, deduction or player population. Validate business meaning and reconcile a representative result.