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.