Key Performance Indicators
Total Revenue
$86.7k
2023 – 2024
Total Profit
$17.9k
All orders
Profit Margin
20.6%
Blended avg
Total Orders
57
2023 – 2024
▸ Query powering this chart
WITH monthly AS (
SELECT
strftime('%Y', o.order_date) AS yr,
strftime('%m', o.order_date) AS mo,
ROUND(SUM(oi.sales), 2) AS revenue
FROM orders o
JOIN order_items oi ON o.order_id = oi.order_id
GROUP BY yr, mo
)
SELECT
mo AS month,
MAX(CASE WHEN yr = '2023' THEN revenue END) AS revenue_2023,
MAX(CASE WHEN yr = '2024' THEN revenue END) AS revenue_2024
FROM monthly
GROUP BY mo ORDER BY mo
▸ Query powering this chart
SELECT
p.category,
ROUND(SUM(oi.sales), 2) AS revenue,
ROUND(SUM(oi.profit), 2) AS profit,
ROUND(SUM(oi.profit) /
SUM(oi.sales) * 100, 1) AS margin_pct
FROM order_items oi
JOIN products p
ON oi.product_id = p.product_id
GROUP BY p.category
ORDER BY revenue DESC
▸ Query powering this chart
SELECT
c.region,
ROUND(SUM(oi.sales), 2) AS revenue,
ROUND(SUM(oi.profit), 2) AS profit,
ROUND(SUM(oi.profit) /
SUM(oi.sales) * 100, 1)
AS margin_pct
FROM orders o
JOIN order_items oi
ON o.order_id = oi.order_id
JOIN customers c
ON o.customer_id = c.customer_id
GROUP BY c.region
ORDER BY revenue DESC
▸ Query powering this chart
SELECT
c.segment,
COUNT(DISTINCT o.order_id) AS orders,
ROUND(SUM(oi.sales), 2) AS revenue,
ROUND(SUM(oi.profit) /
SUM(oi.sales) * 100, 1) AS margin_pct,
ROUND(SUM(oi.sales) /
COUNT(DISTINCT o.order_id),
2) AS avg_order_value
FROM orders o
JOIN order_items oi
ON o.order_id = oi.order_id
JOIN customers c
ON o.customer_id = c.customer_id
GROUP BY c.segment
▸ Query powering this chart
SELECT
CASE
WHEN discount = 0 THEN 'No Discount'
WHEN discount <= 0.10 THEN '1–10%'
WHEN discount <= 0.20 THEN '11–20%'
ELSE '20%+'
END AS discount_tier,
ROUND(SUM(profit) /
SUM(sales) * 100, 1) AS margin_pct
FROM order_items
GROUP BY discount_tier
▸ Query powering this table
WITH rep_totals AS (
SELECT
sr.rep_name, sr.region,
ROUND(SUM(oi.sales), 2) AS revenue,
ROUND(SUM(oi.profit) /
SUM(oi.sales)*100, 1) AS margin_pct,
COUNT(DISTINCT
o.order_id) AS total_orders
FROM orders o
JOIN order_items oi ON o.order_id=oi.order_id
JOIN sales_reps sr ON o.rep_id=sr.rep_id
GROUP BY sr.rep_id
)
SELECT
RANK() OVER (ORDER BY revenue DESC) AS rank,
rep_name, region, revenue,
margin_pct, total_orders
FROM rep_totals ORDER BY rank
| # | Rep | Region | Revenue | Margin | Orders |
| 1 | Kevin Wright | South | $35,375 | | 16 |
| 2 | Marcus Lee | West | $23,600 | | 21 |
| 3 | Sarah Johnson | East | $14,520 | | 9 |
| 4 | Diana Torres | Central | $13,254 | | 11 |
▸ Query powering this table
WITH product_totals AS (
SELECT
p.product_name, p.category,
ROUND(SUM(oi.sales), 2) AS revenue,
ROUND(SUM(oi.profit) /
SUM(oi.sales)*100, 1) AS margin_pct
FROM order_items oi
JOIN products p
ON oi.product_id = p.product_id
GROUP BY p.product_id
)
SELECT
RANK() OVER
(ORDER BY revenue DESC) AS rank,
product_name, category,
revenue, margin_pct
FROM product_totals
ORDER BY rank LIMIT 8
| # | Product | Category | Revenue | Margin |
| 1 | MacBook Pro 16" | Technology | $35,600 | |
| 2 | Dell Monitor 27" | Technology | $11,600 | |
| 3 | Canon EOS Camera | Technology | $9,500 | |
| 4 | Conference Table | Furniture | $9,000 | |
| 5 | Ergonomic Chair | Furniture | $5,730 | |
| 6 | Standing Desk | Furniture | $5,490 | |
| 7 | Bookcases Oak | Furniture | $3,630 | |
| 8 | HP LaserJet Printer | Technology | $3,180 | |