Interactive SQL execution in your browser using DuckDB WASM - loaded from unpkg CDN
Ctrl+Enter (Mac: Cmd+Enter) to executeCtrl+Backspace (Mac: Cmd+Backspace) to restore the original codeCtrl+Shift+Enter (Mac: Cmd+Shift+Enter) to open your query in the full SQL Workbenchunpkg.com as a UMD module (non-ESM)A simple SELECT query to get started. Try modifying the numbers!
SELECT
'Hello' AS greeting,
'World' AS target,
42 AS answer,
3.14159 AS pi;
Generate a sequence of numbers and perform calculations:
SELECT
n AS number,
n * n AS square,
n * n * n AS cube,
CASE
WHEN n % 2 = 0 THEN 'Even'
ELSE 'Odd'
END AS parity
FROM generate_series(1, 10) AS t(n);
Group data and perform aggregations:
WITH sales_data AS (
SELECT
unnest(['Electronics', 'Clothing', 'Electronics', 'Food', 'Clothing', 'Electronics', 'Food', 'Food']) AS category,
unnest([1200, 450, 890, 230, 620, 1500, 180, 340]) AS amount
)
SELECT
category,
COUNT(*) AS transaction_count,
SUM(amount) AS total_sales,
AVG(amount) AS avg_sale,
MAX(amount) AS max_sale
FROM sales_data
GROUP BY category
ORDER BY total_sales DESC;
Work with dates and time:
SELECT
CURRENT_DATE AS today,
CURRENT_DATE - INTERVAL '7 days' AS last_week,
CURRENT_DATE + INTERVAL '30 days' AS next_month,
EXTRACT(year FROM CURRENT_DATE) AS current_year,
EXTRACT(month FROM CURRENT_DATE) AS current_month,
EXTRACT(day FROM CURRENT_DATE) AS current_day;
Use window functions for advanced analytics:
WITH employee_data AS (
SELECT
unnest(['Alice', 'Bob', 'Carol', 'David', 'Eve']) AS name,
unnest(['Sales', 'Sales', 'Engineering', 'Engineering', 'Sales']) AS department,
unnest([75000, 82000, 95000, 88000, 79000]) AS salary
)
SELECT
name,
department,
salary,
AVG(salary) OVER (PARTITION BY department) AS dept_avg_salary,
RANK() OVER (PARTITION BY department ORDER BY salary DESC) AS dept_rank,
RANK() OVER (ORDER BY salary DESC) AS company_rank
FROM employee_data
ORDER BY department, salary DESC;
Demonstrating custom theme usage with different color schemes.
SELECT 'Ocean theme' AS theme_name, 'Extends dark theme' AS description;
SELECT 'Sunset theme' AS theme_name, 'Standalone theme' AS description;