Make sure to click on the Smart Table Save button to store the changes for the page viewers.

Create SQL table

To create an SQL table from Smart Tables data, open the + View menu and click on SQL table. SQL tables are created and managed exclusively from the Confluence page viewer.

SQL tables allow you to reshape and summarize data by writing SQL queries. Conditions, groupings, sorting, and aggregate functions let you narrow results down to exactly the records that matter, whether that means counting occurrences, totaling values, or filtering out what's irrelevant. Because queries run right on your Smart Tables data, you can quickly build a custom view tailored to a specific question, turning raw rows into a clear, actionable answer.

The result is displayed as its own table on the Confluence page and stays in sync with the Smart Table it draws from.

If you're not comfortable writing SQL, AI Mode lets you describe what you need in plain language and generates the query for you. AI Mode is available only when a Confluence administrator has enabled the AI Engine.

Settings

Options

  • Style: Custom height

  • Labels: SQL table title

Delete

From the Settings menu, you can delete the SQL table.

Additional settings are available under the Global View.

Edit mode

The edit mode is enabled by default when a new SQL table is created. To see the SQL table as page viewers do, toggle off edit mode using the edit button in the top-left corner.

The toolbar in the top-left corner lets you switch between two modes:

  • SQL: Write standard SQL directly against your Smart Tables data.
  • AI Mode: Describe the query you need in plain language and let the AI Engine generate it. The query is generated using Atlassian‑hosted LLMs powered by Anthropic's Haiku 4.5.

To run a query, add it to the SQL editor and click the Run Query button or click Enter. The result appears below the editor. Reference the source table as T1, and wrap any column name that contains spaces or special characters in backticks:

SELECT SUM(`Daily Budget ($)`) FROM T1
CODE
The SQL table is part of the Smart Tables macro, so only the users who can edit the Confluence page can edit the SQL table and use the AI Mode.

AI Mode

When the AI Engine is enabled, AI Mode lets you generate a query without writing SQL yourself. It's useful for getting started quickly, for one-off questions, or as a first draft to be refined afterward.

To generate a query with AI:

  1. Click AI Mode in the toolbar
  2. In the prompt box, describe the result you want in plain language, for example "Show total sales for January"
  3. Click the Run Query button and the prompt will be executed
  4. The SQL editor will switch automatically and you will be able to review the produced table and the generated query
AI-generated queries are a starting point, not a finished answer. The AI works from your table's columns and your description, so it can misread an ambiguous request or produce a query that runs but doesn't return what you intended. Review the generated SQL and its results before publishing, especially for complex requests.
If AI Mode doesn't appear in the toolbar, the AI Engine isn't enabled for your site. See Enabling the AI Engine.

Examples

The following examples illustrate common questions you can answer with an SQL table. They query the source table as T1; adjust the column names and conditions to match your own data.

Total a numeric column across every row:

SELECT SUM(`Daily Budget ($)`) FROM T1
CODE

Average a value for each group:

SELECT
  Status,
  AVG(Budget) AS AverageBudget
FROM T1
GROUP BY Status 
CODE

Count how many rows fall into each category, most frequent first:

SELECT Status, COUNT(*) AS Total
FROM T1
GROUP BY Status
ORDER BY Total DESC
CODE

Keep only the groups that exceed a threshold:

SELECT Owner, SUM(Budget) AS TotalBudget
FROM T1
WHERE Status = 'Booked'
GROUP BY Owner
HAVING SUM(Budget) > 1000
CODE

Return different values based on a condition:

SELECT
  Task,
  CASE
    WHEN Priority = 'High' THEN 'Escalate'
    ELSE 'Monitor'
  END AS Action
FROM T1
CODE

Supported SQL

The following table lists all the SQL keywords and functions covered by SQL tables.

CategoryDescriptionClauses / Functions
ClausesDefine what a query pulls and how the results are arrangedSELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET, TOP
Logical and comparison operatorsUsed inside WHERE or HAVING conditionsAND, OR, NOT, IN, IS, LIKE, BETWEEN, ALL, ANY, EXISTS
Conditional expressionsReturn different values based on conditionsCASE, WHEN, THEN, ELSE, END
Aggregate functionsCalculate a single value across a group of rowsCOUNT, SUM, AVG, MIN, MAX
ModifiersChange how results are named, sorted, or deduplicatedAS, ASC, DESC, DISTINCT
SQL tables are not copied when a page is copied. They need to be added again to the new page.