- π Course Information
- π Business Problem
- ποΈ Database Schema
- ποΈ ER Diagram
- π Repository Structure
- βοΈ How to Run
- π Key Queries
- π Key Findings
- π Academic Integrity
- π Contribution Guidelines
- π Clone and Explore
- π Credits
- π License
- Course: Database Development with PL/SQL (INSY 8311) β Mastery Project
- Student: Ushindi Bihame Victoire
- Instructor: Eric Maniraguha
- Date: 25 Sep - 29 Sep 2025
The project analyzes customer and product performance using PL/SQL window functions:
- Identify top products and customers.
- Quantify monthly sales trends & running totals.
- Measure growth over time.
- Segment customers into quartiles for marketing.
- Compute moving averages for forecasting inventory.
π Helps business improve marketing and inventory management decisions.
- customers β customer_id, name, region, created_at
- products β product_id, name, category
- transactions β transaction_id, customer_id, product_id, sale_date, quantity, amount
- Primary keys on all tables.
- Foreign keys:
transactions.customer_id β customers,transactions.product_id β products. - Indexes on
sale_date,customer_id,product_id.
erDiagram
CUSTOMERS {
int customer_id PK
text name
text region
date created_at
}
PRODUCTS {
int product_id PK
text name
text category
}
TRANSACTIONS {
int transaction_id PK
int customer_id FK
int product_id FK
date sale_date
int quantity
numeric amount
}
CUSTOMERS ||--o{ TRANSACTIONS : "purchases"
PRODUCTS ||--o{ TRANSACTIONS : "sold in"
plsql-window-functions-Ushindi-Victoire/
βββ schema/
β βββ schema_and_sample_data.sql # Tables + sample inserts
βββ queries/
β βββ 01_ranking.sql # Query A - Ranking
β βββ 02_aggregate_running_total_A.sql # Query B1 - Running total (ROWS)
β βββ 02_aggregate_running_total_B.sql # Query B2 - Running total (RANGE)
β βββ 03_navigation_lag_lead.sql # Query C - Month-over-Month growth
β βββ 04_distribution_ntile_cume_dist.sql # Query D - Quartiles & CUME_DIST
β βββ 05_moving_avg.sql # Query E - Moving averages
β βββ revenue_analysis.sql # Revenue queries (top quartile etc.)
βββ analysis/
β βββ analysis.md # Descriptive + prescriptive insights
βββ screenshots/ # Query execution results
βββ references.md # References & academic integrity
βββ LICENSE.txt # MIT License
βββ README.md # Project overview
- Create database
plsql_window_dbin pgAdmin 4 (or use VS Code with PostgreSQL extension). - Run
schema/schema_and_sample_data.sqlto create tables and load data. - Execute queries inside
queries/to reproduce results. - Compare results with screenshots in
screenshots/.
- Ranking:
ROW_NUMBER(),RANK(),DENSE_RANK(),PERCENT_RANK()β top customers. - Aggregate:
SUM(),AVG(),MIN(),MAX()withROWS&RANGEframes β trends & totals. - Navigation:
LAG(),LEAD()β month-over-month growth. - Distribution:
NTILE(4),CUME_DIST()β segment customers into quartiles. - Moving averages:
AVG() OVER()β 3-month rolling average. - Revenue analysis: total revenue, quartiles, % of top 25% contribution.
- Top 25% of customers contributed ~52.94% of revenue β loyalty program recommended.
- Seasonal spikes in April & June β plan inventory ahead.
- Coffee Beans 1kg dominates sales β allocate more stock to this product.
All sources are cited in references.md.
All queries and analysis are original.
No AI-generated text/code copied without attribution.
- Use uppercase SQL keywords & consistent formatting.
- Add documentation when introducing new queries.
- Include screenshots for new query results.
- Follow MIT License rules.
git clone https://github.com/ub-victor/plsql-window-functions-ushindi-Victoire.git
cd plsql-window-functions-ushindi-Victoire- Assignment by Lecturer Eric Maniraguha
- Developed by Ushindi Bihame Victoire
- GitHub: ub-victor
This project is licensed under the MIT License.
See LICENSE.txt for details.