dbxlite includes 19 ready-to-run examples that teach SQL concepts from basics to advanced analytics. Each example can be loaded instantly via URL.
Quick Start Examples
Get started with simple DuckDB queries that demonstrate core concepts.
Temp Tables
Create temporary tables from inline values and run aggregations.
-- Create a temp table from inline values
CREATE OR REPLACE TEMP TABLE sales AS
SELECT * FROM (
VALUES
('2024-01-01', 'West', 120),
('2024-01-02', 'West', 95),
('2024-01-01', 'East', 200),
('2024-01-02', 'East', 155)
) AS t(order_date, region, amount);
-- Summarize totals by region
SELECT
region,
SUM(amount) AS total_amount,
AVG(amount) AS avg_amount
FROM sales
GROUP BY region
ORDER BY total_amount DESC;
Generate Series
Use generate_series() to create data programmatically.
-- Generate numbers 1..12 and label quarters
WITH nums AS (
SELECT generate_series AS month_num
FROM generate_series(1, 12)
)
SELECT
month_num,
CASE
WHEN month_num <= 3 THEN 'Q1'
WHEN month_num <= 6 THEN 'Q2'
WHEN month_num <= 9 THEN 'Q3'
ELSE 'Q4'
END AS quarter,
month_num * month_num AS squared
FROM nums;
Remote Data Examples
Query CSV and Parquet files directly from URLs - no upload required.
Classic Datasets
Analyze three popular datasets: Diamonds (54K rows), Titanic (891 passengers), and Gapminder (world development data).
-- Query diamonds dataset directly from GitHub
SELECT
cut,
COUNT(*) AS count,
ROUND(AVG(price), 2) AS avg_price,
MIN(price) AS min_price,
MAX(price) AS max_price
FROM 'https://raw.githubusercontent.com/tidyverse/ggplot2/main/data-raw/diamonds.csv'
GROUP BY cut
ORDER BY avg_price DESC;
Wikipedia Pageviews
Query Wikipedia data from Hugging Face's Parquet files.
SELECT *
FROM 'https://huggingface.co/datasets/wikimedia/wikipedia/resolve/main/20231101.ab/train-00000-of-00001.parquet'
LIMIT 1000;
COVID-19 Statistics
Analyze global COVID-19 data from Our World in Data.
SELECT *
FROM 'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv'
LIMIT 1000;
World Population
Query historical world population data.
US Baby Names
Explore baby name trends from 1880 to present using SSA data.
Learn DuckDB
Comprehensive tutorials covering DuckDB's powerful features.
DuckDB Feature Tour
150+ lines covering CTEs, window functions, JSON operations, pivots, and more.
Topics covered:
- Creating and populating tables
- Window functions (RANK, DENSE_RANK, LAG)
- Common Table Expressions (CTEs)
- Date/time functions
- String manipulation
- Aggregations with FILTER clause
- PIVOT operations
- List and Struct types
- JSON operations
DuckDB Advanced Functions
500+ lines exploring advanced DuckDB features for power users.
Topics covered:
- QUALIFY clause for window function filtering
- Advanced window frames (ROWS vs RANGE vs GROUPS)
- GROUPING SETS, CUBE, ROLLUP
- List/Array functions and comprehensions
- MAP operations
- Recursive CTEs (Fibonacci, org charts)
- ASOF joins for time-series
- SAMPLE and approximate functions
- EXCLUDE and REPLACE in SELECT
- Custom MACROS
- COLUMNS expression for dynamic selection
- FROM-first syntax
- UNION BY NAME
DuckDB Data Types
Test all DuckDB data types with practical examples.
Types covered:
- Integers (TINYINT to HUGEINT, signed and unsigned)
- Floating point (FLOAT, DOUBLE, infinity, NaN)
- Decimal/Numeric with various precisions
- Strings (VARCHAR, Unicode, multiline)
- Boolean, Date, Time, Timestamp, Interval
- Arrays/Lists, Structs, Maps
- UUID, BLOB, JSON, Enum
- NULL handling and type casting
DuckDB Extensions
Extend DuckDB's capabilities with built-in and community extensions.
Core Extensions
TPC-H benchmark data generation, Full-Text Search, Spatial/GIS, and JSON operations.
Extensions demonstrated:
- TPC-H: Generate realistic benchmark data
- FTS: Full-text search with BM25 ranking
- Spatial: ST_Point, ST_Distance, GeoJSON
- JSON: Extract, query, and aggregate JSON data
Community Extensions
Uber's H3 hexagonal geospatial system and Rapidfuzz string matching.
Extensions demonstrated:
- H3: Hexagonal hierarchical geospatial indexing
- Rapidfuzz: Fuzzy string matching and similarity
BigQuery Examples
Query Google BigQuery datasets directly from your browser (requires Google authentication).
BigQuery Advanced Functions
600+ lines covering arrays, structs, window functions, JSON, geography, and more.
Topics covered:
- Array creation and operations
- UNNEST for flattening
- STRUCTs (simple and nested)
- Window functions
- Date/Time functions
- Regular expressions
- JSON functions
- Approximate aggregates
- PIVOT/UNPIVOT
- Recursive CTEs
- Geography functions
BigQuery Data Types
Test all BigQuery data types with comprehensive examples.
Public Datasets
Query real-world data from BigQuery's public datasets.
| Dataset | Description | Link |
|---|---|---|
| GitHub Archive | GitHub events data | Open |
| Stack Overflow | Top Python questions | Open |
| NYC Taxi | Yellow taxi trip analysis | Open |
URL Parameters
Control dbxlite behavior via URL parameters for sharing and embedding.
Loading Examples
| Parameter | Description | Example |
|---|---|---|
example | Load a built-in example by ID | ?example=duckdb-temp |
run | Auto-execute the query | ?example=duckdb-temp&run=true |
tab | Set custom tab name | ?example=wikipedia&tab=Wiki%20Data |
Direct SQL
Pass SQL directly in the URL (must be URL-encoded).
sql.dbxlite.com/?sql=SELECT%201%20as%20test
sql.dbxlite.com/?sql=SELECT%20*%20FROM%20range(10)&run=true
Sharing via Gist
Share longer queries using GitHub Gists. See our detailed guide on sharing SQL for a complete walkthrough with working examples.
sql.dbxlite.com/?share=gist:YOUR_GIST_ID&run=true
Display Options
| Parameter | Description | Values |
|---|---|---|
theme | Set editor color theme | dracula, nord, tokyo-night, catppuccin, github-light, solarized-light, ayu-light |
explorer | Show schema explorer | true, false |
Combined Examples
# Example with Dracula theme
sql.dbxlite.com/?example=duckdb-temp&run=true&theme=dracula
# Example with Nord theme
sql.dbxlite.com/?example=wikipedia&run=true&theme=nord
# Example with Tokyo Night theme
sql.dbxlite.com/?example=remote-datasets&run=true&theme=tokyo-night
# Example with Catppuccin theme
sql.dbxlite.com/?example=duckdb-feature-tour&run=true&theme=catppuccin
# Light themes
sql.dbxlite.com/?example=covid&run=true&theme=github-light
sql.dbxlite.com/?example=population&run=true&theme=solarized-light
sql.dbxlite.com/?example=baby-names&run=true&theme=ayu-light
# Direct SQL with theme
sql.dbxlite.com/?sql=SELECT%20now()&tab=Timestamp&run=true&theme=nord
# Gist with all options
sql.dbxlite.com/?share=gist:abc123&run=true&theme=catppuccin&explorer=true
All Examples Reference
| Category | Example | Theme | Link |
|---|---|---|---|
| Basics | Temp Tables | Dracula | Open |
| Basics | Generate Series | Nord | Open |
| Tutorials | Feature Tour | Dracula | Open |
| Tutorials | Advanced Functions | Nord | Open |
| Tutorials | Data Types | Tokyo Night | Open |
| Remote | Classic Datasets | Tokyo Night | Open |
| Remote | Wikipedia | Catppuccin | Open |
| Remote | COVID-19 | GitHub Light | Open |
| Remote | Population | Solarized Light | Open |
| Remote | Baby Names | Ayu Light | Open |
| Extensions | Core Extensions | Catppuccin | Open |
| Extensions | Community | GitHub Light | Open |
| BigQuery | Advanced Functions | Solarized Light | Open |
| BigQuery | Data Types | Ayu Light | Open |
| BigQuery | GitHub Archive | Dracula | Open |
| BigQuery | Stack Overflow | Nord | Open |
| BigQuery | NYC Taxi | Tokyo Night | Open |