No credit cardStart free

SQL Basics

rawquery uses DuckDB SQL - standard SQL with some nice extras.

Table Naming

Tables are namespaced by connection name:

sql
-- Format: connection_name.table_name
-- The schema is the name YOU gave the connection
SELECT * FROM my_stripe.customers;
SELECT * FROM prod_db.users;
SELECT * FROM crm.contacts;
SELECT * FROM sf.Account;
SELECT * FROM shop.orders;

Basic Queries

SELECT

sql
-- All columns
SELECT * FROM my_stripe.customers LIMIT 10;
-- Specific columns
SELECT id, email, name FROM my_stripe.customers;
-- With alias
SELECT
email AS customer_email,
created AS signup_date
FROM my_stripe.customers;

WHERE

sql
-- Equality
SELECT * FROM my_stripe.charges WHERE status = 'succeeded';
-- Comparison
SELECT * FROM my_stripe.charges WHERE amount > 10000;
-- Multiple conditions
SELECT * FROM my_stripe.charges
WHERE status = 'succeeded'
AND amount > 10000
AND created > '2024-01-01';
-- IN
SELECT * FROM my_stripe.customers
WHERE country IN ('US', 'CA', 'UK');
-- LIKE
SELECT * FROM crm.contacts
WHERE email LIKE '%@company.com';

GROUP BY

sql
-- Count by status
SELECT status, COUNT(*) AS count
FROM my_stripe.charges
GROUP BY status;
-- Sum by month
SELECT
DATE_TRUNC('month', created) AS month,
SUM(amount) / 100.0 AS revenue
FROM my_stripe.charges
WHERE status = 'succeeded'
GROUP BY 1
ORDER BY 1;

ORDER BY

sql
-- Ascending (default)
SELECT * FROM my_stripe.customers ORDER BY created;
-- Descending
SELECT * FROM my_stripe.customers ORDER BY created DESC;
-- Multiple columns
SELECT * FROM my_stripe.charges
ORDER BY amount DESC, created DESC;

Aggregation Functions

FunctionDescription
COUNT(*)Count rows
COUNT(DISTINCT col)Count unique values
SUM(col)Sum values
AVG(col)Average value
MIN(col)Minimum value
MAX(col)Maximum value

Time Travel

rawquery stores your data as Iceberg tables, which keep a history of snapshots. You can query data as it was at any point in time using the FOR SYSTEM_TIME AS OF clause.

sql
-- Query data as of a specific date
SELECT * FROM my_stripe.charges FOR SYSTEM_TIME AS OF '2024-01-15';
-- Full ISO 8601 timestamp
SELECT * FROM my_stripe.charges FOR SYSTEM_TIME AS OF '2024-01-15T14:30:00';
-- With timezone
SELECT * FROM my_stripe.charges FOR SYSTEM_TIME AS OF '2024-01-15T14:30:00+02:00';
-- Compare current vs historical data
SELECT
'now' AS snapshot,
COUNT(*) AS total
FROM my_stripe.customers
UNION ALL
SELECT
'jan-2024' AS snapshot,
COUNT(*) AS total
FROM my_stripe.customers FOR SYSTEM_TIME AS OF '2024-01-01';

Time travel only works with synced (Iceberg) tables, not live connections. The available history depends on how long your data has been syncing.

Query History

The query editor automatically saves your last 50 queries to your browser's local storage. Each entry records the SQL, timestamp, row count, and execution time.

  • Click History in the toolbar to open the history dropdown
  • Click any entry to load it back into the editor
  • Failed queries are marked with an error badge
  • Use Clear all to remove all saved history

History is stored per browser. It is not synced across devices or shared with other workspace members.

Query Editor | Saved Queries | Joins