Query Statistical Data
query_tableRetrieve specific statistical data from Finnish StatFin tables by defining variable selections and filters for precise results.
Instructions
Execute a query to retrieve actual statistical data from a table.
WORKFLOW: search_statistics → get_table_metadata → query_table
Selection types:
filter: "item" + values: ["KU091", "2024"] → specific values
filter: "top" + top: 5 → latest 5 values (good for time variables)
filter: "all" → all values (use carefully, can be large!)
Example - Helsinki population for last 5 years (the variable codes below are from table 11re.px; YOUR table's codes WILL differ - always read them from get_table_metadata first, never reuse these): { "tableId": "11re.px", "selections": [ {"variable": "alue_23_20260101", "filter": "item", "values": ["KU091"]}, {"variable": "timeperiod_y", "filter": "top", "top": 5}, {"variable": "sukupuoli_9_20180101", "filter": "item", "values": ["SSS"]}, {"variable": "ikaryhma_10_20180101", "filter": "item", "values": ["SSS"]}, {"variable": "contentscode", "filter": "item", "values": ["vaerak-vaesto"]} ] }
IMPORTANT: Variable codes are table-specific; get them from get_table_metadata. Use VALUE CODES (KU091, SSS), not labels (Helsinki, Total).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max rows. If query exceeds this, it fails with an error suggesting more specific selections. | |
| tableId | Yes | Table ID from search_statistics or list_tables. Example: "11re.px" | |
| language | No | Label language in results. Default "fi". | fi |
| selections | Yes | One entry per variable. IMPORTANT: Include all non-optional variables or query will return too much data. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Query results (only present if success=true) | |
| error | No | Error message (only present if success=false) | |
| success | Yes | True if query succeeded, false if error | |
| metadata | No | Dataset metadata (source, last updated, label) | |
| rowCount | No | Number of data rows returned | |
| queryInfo | Yes | Query execution metadata |