Busabase
Busabase is an open-source (MIT) database and workspace for AI agents — data, docs, skills, and apps in one place. Run it locally, self-host it inside your network, or use Busabase Cloud, and turn age
翻译准备中
尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证10 SQL analyses of 1M real retail sales lines (cohorts, RFM, Lorenz/Gini, market basket), run live in the browser with DuckDB-WASM
翻译准备中
取自仓库 README
正在加载完整 README。 以下为已保存的摘录。
Ten SQL analyses of one million real online-retail sales lines, run live in your browser.
The data is two years of transactions (Dec 2009 – Dec 2011) from a UK online gift wholesaler.
I cleaned it with SQL, then wrote ten SQL queries that each answer one business question.
The dashboard has no server. DuckDB-WASM runs a
real SQL database inside the browser tab, so:查看完整 README ↗Ten SQL analyses of one million real online-retail sales lines, run live in your browser.
The data is two years of transactions (Dec 2009 – Dec 2011) from a UK online gift retailer (many of its customers are wholesalers). I cleaned it with SQL, then wrote ten SQL queries that each answer one business question.
The dashboard has no server. DuckDB-WASM runs a real SQL database inside the browser tab, so:
The same .sql files run in the browser and in a Python test on GitHub Actions, so the code you
read here is exactly the code that drew the charts.
| # | Question | SQL techniques | Finding (full period) |
|---|---|---|---|
| 01 | How big is the business? | FILTER clauses, COUNT DISTINCT | £18.9M net revenue, 39,516 orders, 5,875 customers, £497 per order |
| 02 | Is it growing, and how seasonal is it? | CTEs, date_trunc, self-join on dates | Every autumn builds to a November peak (£1.43M in Nov 2011, +2.3% on Nov 2010) |
| 03 | Which markets matter? | window functions over aggregates, RANK | UK = 85% of revenue, but overseas orders are bigger (£853 vs £464) |
| 04 | Which products earn the most? | aggregate first, then join | The cake stand earns most, even though the jumbo bag sells 3.8× more units |
| 05 | How unequal is spending? | running totals, Gini coefficient in SQL | Top 20% of customers → 77% of revenue; Gini = 0.74 |
| 06 | Who are the best customers, and who is leaving? | NTILE scoring, CASE rules (RFM) | "Champions" are 25% of customers but 70% of revenue; 350 big buyers have gone quiet |
| 07 | Do new customers come back? | cohort analysis, datediff, FIRST_VALUE | Only ~21% re-order the next month; lapsed customers return each November |
| 08 | What is bought together? | self-join, support / confidence / lift | Matching teacups are bought together 21× more often than chance |
| 09 | When do people order? | date parts, heatmap grid | 67% of orders arrive 10:00–15:00; almost none on Saturdays (a B2B business) |
| 10 | What gets returned? | conditional aggregation, thresholds | The worst "return rate" is one 74,215-jar order cancelled 16 minutes later |
The raw Excel file has 1,067,371 rows. etl/clean.sql fixes four problems I
found by exploring the data first:
| Step | Rows removed | Why |
|---|---|---|
| Sheet overlap | 22,523 | The 2009–10 sheet runs to 9 Dec 2010, but the 2010–11 sheet starts on 1 Dec 2010 and repeats those rows exactly |
| Non-product lines | 11,930 | Postage, bank charges, Amazon fees, manual adjustments, test items, zero prices and stock write-offs are not sales of goods |
| Exact duplicates | 11,792 | The same line scanned twice (same invoice, product, quantity, price, time) |
| Clean sales lines | 1,021,126 |
Cancelled orders (invoice numbers starting with C) are kept as negative lines so returns can be
analysed. About 22% of lines have no customer ID; they count towards revenue but are left out of
the customer analyses (05–07).
Excel (UCI) ──► etl/build_data.py ──► etl/clean.sql (DuckDB) ──► data/*.parquet (5.4 MB)
│
browser: DuckDB-WASM loads the Parquet ◄───────┘
filters rewrite one SQL view: `sales`
sql/01–10 run against it ──► ECharts
CREATE OR REPLACE VIEW sales AS SELECT … WHERE …), and
every query reads from sales. Click Filter SQL on the dashboard to see it.etl/run_queries.py runs all ten queries in Python with the same setup.
GitHub Actions runs it on every push, so a broken query fails the build.├── index.html the dashboard page
├── assets/ app.js (DuckDB + filters + playground), charts.js, util.js, app.css
├── sql/ the ten analysis queries (the main work)
├── etl/
│ ├── build_data.py download → load → clean → export Parquet
│ ├── clean.sql all cleaning rules, commented
│ └── run_queries.py runs every query (also the CI test)
└── data/ sales.parquet, products.parquet, cleaning_report.json
git clone https://github.com/Z3US-23/retail-sql-analytics.git
cd retail-sql-analytics
python -m venv .venv
.venv\Scripts\activate # Windows (macOS/Linux: source .venv/bin/activate)
pip install -r requirements.txt
python etl/run_queries.py # run all ten queries in the terminal
python -m http.server 8000 # then open http://localhost:8000
To rebuild the data from the original Excel file: python etl/build_data.py (downloads 45 MB).
Chen, D. (2012). Online Retail II [Data set]. UCI Machine Learning Repository. https://doi.org/10.24432/C5CG6D, licensed CC BY 4.0. Prices are in GBP.
Built by Ahmad Ammar, BS Economics, Forman Christian College, Lahore · Tools: SQL (DuckDB), Python, JavaScript, Apache ECharts.