Skip to content
cccskills
FreePublished on GitHub

sales_analytics

Use defined customer and order tables to build sales analysis queries with consistent business rules. Calculate revenue from completed orders, rank customers by spending, and identify high-value orders using the supplied thresholds and SQL example.

OriginalShow the original description

Database schema and business logic for sales data analysis including customers, orders, and revenue.

See how to install

Good for

  • Ranking the top ten customers by revenue over three months
  • Calculating revenue from completed orders
  • Finding orders with a total amount above 1,000
  • Extracting active customers registered at least 90 days ago

Files included (1)

  • SKILL.md1.3 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Sales Analytics Schema

Tables

customers

  • customer_id (PRIMARY KEY)
  • name
  • email
  • signup_date
  • status (active/inactive)
  • customer_tier (bronze/silver/gold/platinum)

orders

  • order_id (PRIMARY KEY)
  • customer_id (FOREIGN KEY -> customers)
  • order_date
  • status (pending/completed/cancelled/refunded)
  • total_amount
  • sales_region (north/south/east/west)

order_items

  • item_id (PRIMARY KEY)
  • order_id (FOREIGN KEY -> orders)
  • product_id
  • quantity
  • unit_price
  • discount_percent

Business Logic

Active customers: status = 'active' AND signup_date <= CURRENT_DATE - INTERVAL '90 days'

Revenue calculation: Only count orders with status = 'completed'. Use total_amount from orders table.

High-value orders: Orders with total_amount > 1000

Example Query

-- Get top 10 customers by revenue in the last quarter
SELECT c.customer_id, c.name, c.customer_tier, SUM(o.total_amount) as total_revenue
FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
WHERE o.status = 'completed' AND o.order_date >= CURRENT_DATE - INTERVAL '3 months'
GROUP BY c.customer_id, c.name, c.customer_tier
ORDER BY total_revenue DESC LIMIT 10;

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Use a defined database structure and business rules to query products, warehouses, stock levels, and stock movements. It supports inventory checks and SQL for identifying products whose combined warehouse stock has reached the reorder threshold.

  • Checking stock quantities by product and warehouse
  • Finding products at or below their reorder threshold
  • Understanding records for stock movements
alibaba/spring-ai-alibaba11KUpdated Oct 7, 2026

See all skills by alibaba

Report a problem with this skill