# When a Query Answer Looks Wrong

A number that looks wrong has several possible authors: the request you made, the skills that shaped the SQL, the statement itself, the query engine, or the model's reading of what came back. This page is the triage — it maps a symptom to the layer that produced it, so you spend your time where the fix is. For why answers vary in the first place, and how to stop them varying across a team, see [Getting Reliable Answers](/products/ai-studio/concepts/reliable-answers).

Check these two first
**Is the SQL what you meant?** Expand the tool call and read the statement — that is the question your data actually answered. **Are the SQL skills on?** They are not enabled by default, and without them the agent writes generic SQL. See [Turn On the SQL Skills](/products/ai-studio/query/query-execution#turn-on-the-sql-skills).

## Prerequisites

- Signed in to Treasure AI Studio ([Getting Started](/products/ai-studio/getting-started))
- Familiarity with reading a tool call ([Reading Query Results](/products/ai-studio/query/query-results))


## What to Check When an Answer Looks Wrong

| Symptom  | Most likely cause  | What to do  |
|  --- | --- | --- |
| The SQL avoids TD functions, scans whole tables, or uses the wrong engine | Skills | Enable **sql-skills** in **Settings → Marketplace** — it is not on by default. See [Turn On the SQL Skills](/products/ai-studio/query/query-execution#turn-on-the-sql-skills) |
| The number is plausible but wrong by an order of magnitude | The SQL | Read the statement: often a missing time bound, a join that multiplies rows, or the wrong table |
| Test or cancelled records are counted | Your request | Those filters exist only if someone stated them. Say the exclusion and re-run — then write it down where it applies every time ([Where Your Business Knowledge Belongs](/products/ai-studio/concepts/reliable-answers#where-your-business-knowledge-belongs)) |
| Two runs of the same question disagree | Request + context | Fix the table, period, and filters in the prompt, and move the standing ones into instructions or a skill — see [Getting Reliable Answers](/products/ai-studio/concepts/reliable-answers) |
| The query fails on memory, or takes minutes | The engine | Narrow the time range first, then ask for the `trino-optimizer` skill. If it still will not run on Trino, it has to be rewritten for Hive and submitted as a job — see [Trino Runs in the Chat; Hive Runs as a Job](/products/ai-studio/query/query-execution#trino-runs-in-the-chat-hive-runs-as-a-job) |
| The figures are right but the conclusion is invented | Interpretation | Treat the analysis as a draft. Ask what the claim is based on, and check it against the tool output |
| Quality dropped after a new skill was installed | Custom skills | A skill's instructions apply to every matching request. Turn the suspect plugin off, ask again, and compare |
| The chat gets vaguer the longer it runs | Context, not SQL | A large result or a long session leaves less room for what comes next. Start a new chat — see [In-Session Memory](/products/ai-studio/chat/in-session-memory) |


## Reading the Query Itself

Most wrong numbers are visible in the statement, and three things account for most of them:

- **The table it chose.** The agent picks from what it discovered; a similarly named table is easy to miss in prose and obvious in the `FROM` clause.
- **The time bound.** A missing or wrong interval is a common reason a figure comes back off by an order of magnitude.
- **The filters you assumed.** Test accounts, cancelled orders, and soft-deleted rows are excluded only if someone said so.


Correct the specific thing rather than asking again from scratch — "exclude rows where `status = 'test'` and re-run" keeps the rest of the query intact.

Connected warehouses
Snowflake and Databricks are queried through their connector rather than `tdx`, so the skills and engine rows above do not apply — the dialect, the permissions, and the error messages are the warehouse's own. The rest of this triage still holds: read the statement in the tool call, and treat the summary as an interpretation. See [Querying a Connected Warehouse](/products/ai-studio/query/query-execution#querying-a-connected-warehouse).

## Pinning It Down

If the triage above has not settled it, work through this checklist. Each step rules out one layer, and most problems are solved before the list ends — an answer that cannot be reproduced was usually a one-off, and one that reproduces tells you exactly where it lives.

- [ ] **Ask the same question again in a new chat.** If it does not reproduce, the earlier conversation's context was the cause, not the query
- [ ] **Run the SQL from the tool call yourself**, in the console or Treasure Code. Same number? Then the query is sound and the problem is upstream in your request or downstream in the summary
- [ ] **Toggle the suspect plugin off** and repeat the request. Change one plugin at a time
- [ ] **Read the work folder's instructions and your organization's custom instruction.** A standing rule you forgot about explains a surprising number of "wrong" answers
- [ ] **Check the figures in the reply against the raw output** one more time — the disagreement may be in the restatement, not the data


What you are left with is a record: the SQL that ran, the request you made verbatim, the plugins that were enabled, the instructions in force, the job id if the query reached the engine, and the result you expected instead. Keep it with the chat. If you do need help — from a colleague who knows the data, or from support — that record is what makes the problem reproducible for them, and saying which layers you already ruled out saves everyone a round.

## Next Steps

- [Getting Reliable Answers](/products/ai-studio/concepts/reliable-answers) — Why answers vary, and where to define your conventions so they stop
- [Querying Treasure Data CDP](/products/ai-studio/query/query-execution) — How a question becomes SQL, and how to review it
- [Reading Query Results](/products/ai-studio/query/query-results) — Raw output versus the agent's restatement
- [Skills & Marketplace](/products/ai-studio/skills/skills) — Enabling the plugins that shape the SQL