Case study · AI & Data

Ask Your Data: business questions answered in seconds

A text-to-SQL assistant that lets anyone ask questions about company data in plain language and see the answer together with the SQL behind it.

n8nPostgreSQLLocal LLM (Qwen3-8B)LM Studio

The challenge

Dashboards answer the questions someone planned for. Every follow-up (“And only Bavaria? Only Q4?”) goes to an analyst and waits in a queue.

Before

  • Questions wait for an analyst
  • Every follow-up is a new request
  • Answers arrive days later

After

  • Ask in German, English or Russian
  • Answer with table and SQL in about 3 seconds
  • Follow-ups understood in context

See it in action

Wie hoch war der Umsatz von BMW im Jahr 2025?
2.320.839.404,63 EUR
Und nur im vierten Quartal?
589.775.682,17 EUR
Und jetzt nur Bayern?
89.303.318,19 EUR

Real exchange from the demo (German data, German questions).

The agent remembers the conversation and writes a complete SQL query every time: BMW, 2025, Q4, Bayern. The SQL is always shown, so every number can be checked.

How it works

Chat or webhook → SQL agent with local LLM and memory → SQL validator → read-only PostgreSQL → short answer with table and SQL.

Architecture of the Ask Your Data assistant

Safe by design: four layers

1 · Read-only role

SELECT on one view only. No access to base tables, no writes.

2 · 5-second timeout

Slow or runaway queries are cancelled by the database.

3 · SQL validator

One SELECT only. Data changes, system schemas and multiple statements are rejected.

4 · 100-row limit

Every query is wrapped with a row limit before it runs.

Measured, not claimed

94%

17 of 18 correct on new test questions never used for tuning

~3 s

average answer time with a small local model (8B parameters)

100%

local: no question and no data leaves the machine

The main set of 25 questions (25/25) was used to tune the prompt, so we report the holdout result. The one miss was an integer-division error, which is why the SQL is always shown next to the answer.

Where it fits

Any team with data in a SQL database and recurring questions about it.

E-commerce

Which products drove the most revenue in October?

Retail & distribution

Which regions fell behind last quarter?

Logistics

How many deliveries were late this month?

Manufacturing

How much scrap did line 3 produce this week?

Finance & controlling

Which cost centres are over budget?

Marketing

Which campaign had the best ROI this quarter?

Works best with a clean SQL data source and clear metric definitions. Personal data stays out of the view or is pseudonymised.

Want this on your own data?

Tell us your main challenge. We reply within 24 hours with a clear plan: no sales pitch, just honest advice.

Get in touch