SQL Lab
SQL Lab is CalabiIQ's full-featured SQL editor. Write and run queries against any connected database, explore schemas, save queries for reuse, and turn results directly into charts — without leaving the browser.
SQL Lab is available on all tiers. Advanced features (query history sharing, async long-running queries) require Professional tier.
Opening SQL Lab
- Click SQL → SQL Lab in the top navigation, or
- Press
Alt+Qfrom anywhere in CalabiIQ.
Interface Overview
┌─────────────────────────────────────────────────────────────────┐
│ Database selector │ Schema selector │ Table browser (left) │
├─────────────────────────────────────────────────────────────────┤
│ │
│ Query editor (top) │
│ │
├─────────────────────────────────────────────────────────────────┤
│ Results table / Query history / Saved queries (bottom tabs) │
└─────────────────────────────────────────────────────────────────┘
| Pane | Purpose |
|---|---|
| Left sidebar | Browse databases, schemas, tables, and columns |
| Query editor | Write SQL with syntax highlighting and auto-complete |
| Results tab | Tabular output with sorting, searching, and export |
| Query History tab | All queries run in the current session |
| Saved Queries tab | Queries you have bookmarked for later |
Running Queries
Basic run
- Select the Database and Schema from the dropdowns.
- Write your SQL in the editor.
- Click Run or press the keyboard shortcut.
Partial run
Highlight a portion of the SQL, then click Run — only the highlighted text is executed. Useful for testing sub-queries or CTEs.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+R | Run the current query (or selection) |
Ctrl+Enter | Run the current query (or selection) |
Ctrl+Shift+Enter | Run the query and format results |
Ctrl+S | Save the current query |
Ctrl+Z | Undo last edit |
Ctrl+Y | Redo |
Ctrl+/ | Toggle comment on selected lines |
Ctrl+Space | Trigger auto-complete |
Ctrl+A | Select all query text |
F11 | Toggle fullscreen editor |
SQL Examples
Count rows in a table
SELECT COUNT(*) AS total_rows
FROM psychometric_reporting.scores;
Exam pass rates by country
SELECT
c.country_name,
COUNT(*) AS total_attempts,
SUM(CASE WHEN s.passed THEN 1 ELSE 0 END) AS passes,
ROUND(
100.0 * SUM(CASE WHEN s.passed THEN 1 ELSE 0 END) / COUNT(*),
2
) AS pass_rate_pct
FROM psychometric_reporting.scores s
JOIN dim.candidates c ON c.candidate_id = s.candidate_id
WHERE s.exam_date >= DATEADD(month, -3, CURRENT_DATE)
GROUP BY c.country_name
ORDER BY pass_rate_pct DESC
LIMIT 20;
Monthly revenue trend (CTE)
WITH monthly AS (
SELECT
DATE_TRUNC('month', created_at) AS month,
SUM(amount_usd) AS revenue
FROM billing.transactions
WHERE status = 'completed'
GROUP BY 1
)
SELECT
month,
revenue,
revenue - LAG(revenue) OVER (ORDER BY month) AS mom_delta
FROM monthly
ORDER BY month;
Find tables with no description
SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'pg_catalog')
ORDER BY table_schema, table_name;
Schema Explorer
The left sidebar lets you browse your connected databases without writing any SQL:
- Expand the database node.
- Expand a schema.
- Expand a table to see all columns with their data types.
- Click the Preview icon next to a table to run
SELECT * FROM <table> LIMIT 100automatically.
Query Tabs
SQL Lab supports multiple tabs — each tab is an independent query editor with its own results.
- New tab: Click + next to the tab bar.
- Rename tab: Double-click the tab name.
- Close tab: Click × on the tab.
Tabs persist for the duration of your browser session. Use Save to persist a query permanently.
Saving Queries
Save frequently-used queries so they are available across sessions and to teammates.
- Write the query in the editor.
- Press
Ctrl+Sor click Save (floppy disk icon, toolbar). - Enter a Name and optional Description.
- Click Save Query.
Saved queries appear in the Saved Queries tab at the bottom and in SQL → Saved Queries from the navigation.
Sharing a saved query
- Open SQL → Saved Queries.
- Find your query and click Share.
- Copy the link — any CalabiIQ user with database access can open and run it.
Creating Charts from SQL Results
Turn any SQL result set into a chart without re-building a dataset:
- Run a query that produces the columns you want to visualise.
- In the Results tab, click Explore.
- The Chart Editor opens with a virtual dataset built from your query.
- Configure the chart type, metrics, and dimensions as normal.
- Save the chart and optionally add it to a dashboard.
Column aliases in your SQL (SELECT COUNT(*) AS total_exams) become the dimension and metric names in the Chart Editor. Use descriptive aliases for cleaner charts.
Downloading Results
| Format | How |
|---|---|
| CSV | Results tab → Download → CSV |
| Excel (.xlsx) | Results tab → Download → Excel |
| JSON | Results tab → Download → JSON |
Downloads are limited to 10,000 rows by default. To export larger result sets, use the Data → Export feature or contact your Calabi administrator.
Query History
Every query you run is recorded in the Query History tab (bottom of the editor). History shows:
- Query text
- Database and schema
- Run time (ms)
- Row count
- Status (success / failed / running)
- Timestamp
Click any history entry to load the query back into the editor.
Async Queries
Long-running queries (> 30 seconds) are automatically promoted to async mode on Professional+ tenants:
- The query is submitted to a background worker.
- You can close the tab — the query continues running.
- When complete, a notification appears in CalabiIQ.
- Find the result in Query History → click Load results.
Async queries require the Celery background worker to be running in your Calabi deployment. Contact your administrator if long queries time out.