Skip to content

Instantly share code, notes, and snippets.

View Bilbottom's full-sized avatar
🧙
Mathemagicianing

Bill Bilbottom

🧙
Mathemagicianing
View GitHub Profile
@Bilbottom
Bilbottom / duckdb-cross-data-source-query.sql
Last active January 26, 2025 21:16
DuckDB cross-data-source query
/*
DuckDB cross-data-source query
DuckDB version: v1.1.1
Bill Wallis, 2024-12-15
This is just for illustration: the files are purposefully not included in this Gist
*/
@Bilbottom
Bilbottom / csv-1.csv
Created December 4, 2024 09:29
DuckDB CSV diff
id col_1 col_2 col_3
1 a b 0.1
2 c d -11
3 e f 111
@Bilbottom
Bilbottom / connect-by-oracle.sql
Last active October 21, 2024 07:03
Recursive CTEs for graph traversal
/* flatten bus route */
with bus_stops(from_stop, to_stop) as (
select 'BM', 'WQS' from dual
union all select 'CR', 'BM' from dual
union all select 'CS', 'LL' from dual
union all select 'GG', 'CS' from dual
union all select 'LL', 'OS' from dual
union all select 'OS', 'CR' from dual
union all select 'WQS', 'GG' from dual
)
@Bilbottom
Bilbottom / recursive-ctes-data-generation.sql
Created October 18, 2024 05:56
Recursive CTEs for data generation
/*
Recursive CTEs for data generation
DuckDB version: 1.0.0
Bill Wallis, 2024-10-18
*/
select version();
@Bilbottom
Bilbottom / SQL tuple filter performance
Last active September 3, 2024 09:01
SQL tuple filter performance
Creating tables...
Timing SQLite queries...
Start time: 2024-08-31 09:23:05.697240
----------------------------------------
100%|██████████| 10000/10000 [00:02<00:00, 3370.72it/s]
query-1.sql: 0.00008558s (50.1%)
query-2.sql: 0.00008527s (49.9%)
----------------------------------------
End time: 2024-08-31 09:23:08.676550
@Bilbottom
Bilbottom / rollup.sql
Created August 4, 2024 10:43
Using ROLLUP for subtotals
/*
Using ROLLUP for subtotals
DuckDB version: 1.0.0
Bill Wallis, 2024-08-04
*/
select version();
@Bilbottom
Bilbottom / window-clause.sql
Created August 2, 2024 19:48
The WINDOW clause needs some more love
/*
The WINDOW clause needs some more love
DuckDB version: 1.0.0
Bill Wallis, 2024-08-02
*/
select version();
/*
SQL Indexes (specifically SQLite)
SQLite version: 3.45.1
Bill Wallis, 2024-07-27
https://sqlite.org/queryplanner.html
https://use-the-index-luke.com/
*/
@Bilbottom
Bilbottom / three-valued-logic.sql
Created July 27, 2024 07:44
Three-valued logic (SQL)
/*
Three-valued logic
DuckDB version: 1.0.0
Bill Wallis, 2024-07-27
https://modern-sql.com/concept/three-valued-logic
*/
@Bilbottom
Bilbottom / friendly-duckdb-02.sql
Last active August 6, 2024 09:08
Friendly SQL with DuckDB (part 2)
/*
Friendly SQL with DuckDB (part 2)
DuckDB version: 1.0.0
Bill Wallis, 2024-07-27
Demonstrating some DuckDB features described by Alex Monahan at:
https://duckdb.org/docs/sql/dialect/friendly_sql