SQL queries
Turn SQL query results from a connected database into map layers. Write the query yourself or ask Felt AI for help.
Available on the Business and Enterprise plans. Compare plans
Query a connected database with SQL to turn its results into a map layer. Write the query in the SQL editor or ask Felt AI to write it. Refresh the layer manually or on a schedule to update its results.
This page covers SQL on connected databases. To query layers already on your map, ask Felt AI. See AI assistant.
Create a layer from a SQL query
SQL queries work with Postgres / PostGIS, Snowflake, BigQuery, Databricks, Amazon Redshift, Microsoft SQL Server, and Wherobots sources. The results must include a geometry column so Felt can draw the features.
Click Data sources in the toolbar, then select your database source.
Click New SQL query at the top of the source's Recent queries. To start from one table, click the ··· menu on the table and click Write SQL query.
Write your query in the editor, or describe what you want in the Felt AI tab at the bottom of the editor. Felt AI writes the SQL in the editor, where you can review and change it.
Click Preview. The Results tab shows up to 100 rows.
Optional: To make the layer refresh on a schedule, click the arrow next to Create layer, turn on Live, and select a frequency.
Click Create layer. The layer appears on the map, ready to style.
Felt runs only SELECT statements, so a query can't change or delete data in your database. Edits you make to the layer on the map stay in Felt.
To reuse a query, select it in the source's Recent queries. The list shows the 20 most recent queries used to create layers from the source, including other people's queries.
For what to ask Felt AI, see Prompting tips. For the spatial functions your database supports, see its documentation: PostGIS, Snowflake, BigQuery, Databricks, Amazon Redshift, or Microsoft SQL Server.

Refresh a layer from a SQL query
Refreshing a layer from a SQL query reruns the query, so the layer picks up changes in the database. Between refreshes, its results stay the same.
To refresh the layer now, select the layer, open its Data tab, and click Refresh.
To refresh the layer on a schedule, turn on Live in the Data tab and select a frequency.
A refresh replaces edits made to the layer on the map. Each refresh counts toward your workspace's processing limit. See Refresh data.
Edit a layer's SQL query
You can change the SQL query of a layer created from a SQL query at any time, including one Felt AI created from a database source. You need Edit access to the source. A layer Felt AI made by querying map layers has no SQL editor, so ask Felt AI to change it.
In edit mode, select the layer in the legend.
In the detail panel, open the Data tab.
Next to Dataset, click SQL query. The SQL editor opens with the layer's query.
Change the query yourself, or ask Felt AI to change it.
Click Preview to check the results.
Click Save. If the layer has edits made on the map, Felt warns that the new query replaces them. Click Update query to continue.
Felt reprocesses the layer with the new query and keeps its styling.
Fix a query that fails
A SQL query that fails shows There was an issue running this query. in the Results tab, with the database's error message. Click Fix errors with AI to have Felt AI correct the query, or fix it yourself, then click Preview again.
Frequently asked questions
Last updated
Was this helpful?