Skip to content

SQL Queries

SQL queries are queries written in the Compass module against relational database data sources. Pirivision supports three different SQL dialects; each has its own syntax, functions, and considerations.

Type Dialect Port Data Source
PostgreSQL Standard SQL + PostgreSQL extensions PostgreSQL connection
MSSQL T-SQL (Transact-SQL) MSSQL connection
MySQL MySQL SQL MySQL connection

Common Features

Feature Description
SQL Code Editor Syntax highlighting, autocomplete
Table Browser View tables and columns of the connected database within the editor
Parameterized Queries {{param_name}} syntax — bindable to dashboard filters
Caching Results are cached for a configurable duration (default 300 s)
AI Copilot Generate queries from natural language or improve an existing query
Time Series Cartography trend charts via a timestamp column

Dialect Comparison

Feature PostgreSQL MSSQL (T-SQL) MySQL
Row limit LIMIT N TOP N LIMIT N
Current time NOW() GETDATE() NOW()
Date offset NOW() - INTERVAL '7 days' DATEADD(d,-7,GETDATE()) DATE_SUB(NOW(),INTERVAL 7 DAY)
Null fallback COALESCE() ISNULL() IFNULL()
Identifier "column" [column] `column`
Schema prefix schema.table db.schema.table db.table

Which Page Should I Read?

Go to the page that matches the data source type you added in the Port module:

Data Source Type Page
PostgreSQL PostgreSQL Queries
MSSQL MSSQL Queries (T-SQL)
MySQL MySQL Queries