This lesson covers business metrics and Key Performance Indicators (KPIs) that are essential for measuring business success.
Business Metrics
Key Performance Indicators (KPIs)
Strategic Level (Executive KPIs)
Revenue Growth Rate
Market Share
Profit Margin
Customer Satisfaction Score
Employee Engagement
Tactical Level (Department KPIs)
Marketing: Lead Conversion Rate, Cost per Acquisition
Sales: Sales Cycle Length, Win Rate
Operations: Order Fulfillment Time, Quality Score
Finance: Days Sales Outstanding, Budget Variance
Operational Level (Daily Metrics)
Website Traffic
Daily Sales
Support Tickets
Inventory Levels
Production Output
Revenue and Growth Metrics
-- Calculate comprehensive business metrics
WITH revenue_metrics AS (
SELECT
-- Time-based revenue calculations
DATE_TRUNC('month', order_date) as revenue_month,
SUM(order_total) as monthly_revenue,
COUNT(DISTINCT order_id) as monthly_orders,
COUNT(DISTINCT customer_id) as monthly_customers,
-- Growth calculations
LAG(SUM(order_total)) OVER (ORDER BY DATE_TRUNC('month', order_date)) as previous_month_revenue,
LAG(COUNT(DISTINCT customer_id)) OVER (ORDER BY DATE_TRUNC('month', order_date)) as previous_month_customers,
-- Year-over-year comparisons
SUM(order_total) - LAG(SUM(order_total), 12) OVER (ORDER BY DATE_TRUNC('month', order_date)) as yoy_revenue_change,
COUNT(DISTINCT customer_id) - LAG(COUNT(DISTINCT customer_id), 12) OVER (ORDER BY DATE_TRUNC('month', order_date)) as yoy_customer_change
FROM orders
WHERE order_date >= '2022-01-01'
GROUP BY DATE_TRUNC('month', order_date)
),
growth_calculations AS (
SELECT
revenue_month,
monthly_revenue,
monthly_orders,
monthly_customers,
previous_month_revenue,
previous_month_customers,
yoy_revenue_change,
yoy_customer_change,
-- Month-over-month growth rates
CASE
WHEN previous_month_revenue > 0 THEN
(monthly_revenue - previous_month_revenue) / previous_month_revenue * 100
ELSE NULL
END as mom_revenue_growth,
CASE
WHEN previous_month_customers > 0 THEN
(monthly_customers - previous_month_customers) / previous_month_customers * 100
ELSE NULL
END as mom_customer_growth,
-- Year-over-year growth rates
CASE
WHEN LAG(monthly_revenue, 12) OVER (ORDER BY revenue_month) > 0 THEN
yoy_revenue_change / LAG(monthly_revenue, 12) OVER (ORDER BY revenue_month) * 100
ELSE NULL
END as yoy_revenue_growth,
CASE
WHEN LAG(monthly_customers, 12) OVER (ORDER BY revenue_month) > 0 THEN
yoy_customer_change / LAG(monthly_customers, 12) OVER (ORDER BY revenue_month) * 100
ELSE NULL
END as yoy_customer_growth
FROM revenue_metrics
)
SELECT
'Revenue Metrics' as metric_category,
revenue_month as period,
ROUND(monthly_revenue, 2) as monthly_revenue,
ROUND(monthly_orders, 0) as monthly_orders,
ROUND(monthly_customers, 0) as monthly_customers,
ROUND(mom_revenue_growth, 2) as mom_revenue_growth_pct,
ROUND(yoy_revenue_growth, 2) as yoy_revenue_growth_pct,
ROUND(mom_customer_growth, 2) as mom_customer_growth_pct,
ROUND(yoy_customer_growth, 2) as yoy_customer_growth_pct,
-- Performance indicators
CASE
WHEN mom_revenue_growth > 10 THEN 'Strong Growth'
WHEN mom_revenue_growth > 5 THEN 'Moderate Growth'
WHEN mom_revenue_growth > 0 THEN 'Slow Growth'
WHEN mom_revenue_growth < -5 THEN 'Declining'
ELSE 'Stable'
END as revenue_performance,
CASE
WHEN yoy_revenue_growth > 20 THEN 'Excellent'
WHEN yoy_revenue_growth > 10 THEN 'Good'
WHEN yoy_revenue_growth > 0 THEN 'Positive'
ELSE 'Needs Attention'
END as annual_performance
FROM growth_calculations
WHERE revenue_month >= '2023-01-01'
ORDER BY revenue_month;
Customer Metrics
-- Customer acquisition and retention metrics
WITH customer_metrics AS (
SELECT
DATE_TRUNC('month', signup_date) as cohort_month,
COUNT(DISTINCT customer_id) as new_customers,
-- Calculate customer acquisition cost
SUM(marketing_spend) as monthly_marketing_spend,
SUM(marketing_spend) / COUNT(DISTINCT customer_id) as customer_acquisition_cost,
-- Calculate retention rates
COUNT(DISTINCT CASE
WHEN last_purchase_date >= signup_date + INTERVAL '30 days' THEN customer_id
END) as retained_30_days,
COUNT(DISTINCT CASE
WHEN last_purchase_date >= signup_date + INTERVAL '90 days' THEN customer_id
END) as retained_90_days,
COUNT(DISTINCT CASE
WHEN last_purchase_date >= signup_date + INTERVAL '365 days' THEN customer_id
END) as retained_365_days
FROM customers c
LEFT JOIN marketing_spend ms ON DATE_TRUNC('month', c.signup_date) = ms.month
WHERE signup_date >= '2023-01-01'
GROUP BY DATE_TRUNC('month', signup_date)
),
retention_rates AS (
SELECT
cohort_month,
new_customers,
customer_acquisition_cost,
retained_30_days,
retained_90_days,
retained_365_days,
-- Calculate retention percentages
retained_30_days * 100.0 / new_customers as retention_rate_30d,
retained_90_days * 100.0 / new_customers as retention_rate_90d,
retained_365_days * 100.0 / new_customers as retention_rate_365d,
-- Calculate customer lifetime value (simplified)
AVG(total_lifetime_spend) as avg_customer_lifetime_value,
customer_acquisition_cost / NULLIF(AVG(total_lifetime_spend), 0) as ltv_cac_ratio
FROM customer_metrics
GROUP BY cohort_month, new_customers, customer_acquisition_cost,
retained_30_days, retained_90_days, retained_365_days
)
SELECT
'Customer Metrics' as metric_category,
cohort_month as period,
new_customers as new_customers_acquired,
ROUND(customer_acquisition_cost, 2) as cac_amount,
ROUND(retention_rate_30d, 2) as retention_30d_pct,
ROUND(retention_rate_90d, 2) as retention_90d_pct,
ROUND(retention_rate_365d, 2) as retention_365d_pct,
ROUND(avg_customer_lifetime_value, 2) as avg_ltv,
ROUND(ltv_cac_ratio, 2) as ltv_cac_ratio,
-- Performance indicators
CASE
WHEN retention_rate_90d > 80 THEN 'Excellent Retention'
WHEN retention_rate_90d > 60 THEN 'Good Retention'
WHEN retention_rate_90d > 40 THEN 'Average Retention'
ELSE 'Poor Retention'
END as retention_performance,
CASE
WHEN ltv_cac_ratio > 3 THEN 'Excellent LTV:CAC'
WHEN ltv_cac_ratio > 2 THEN 'Good LTV:CAC'
WHEN ltv_cac_ratio > 1 THEN 'Breakeven LTV:CAC'
ELSE 'Poor LTV:CAC'
END as ltv_cac_performance
FROM retention_rates
ORDER BY cohort_month;
Specific
Measurable
Achievable
Relevant
Time-bound
Actionable
Simple
Timely
Comparable
KPI Quality Metrics
-- Assess KPI quality and effectiveness
WITH kpi_definitions AS (
SELECT
kpi_name,
kpi_category,
measurement_frequency,
data_source,
target_value,
current_value,
-- SMART criteria assessment
CASE
WHEN kpi_description LIKE '%increase%' OR kpi_description LIKE '%decrease%' OR kpi_description LIKE '%achieve%' THEN 1
ELSE 0
END as is_specific,
CASE
WHEN measurement_unit IS NOT NULL AND measurement_unit != '' THEN 1
ELSE 0
END as is_measurable,
CASE
WHEN target_value IS NOT NULL AND target_value > 0 THEN 1
ELSE 0
END as is_achievable,
CASE
WHEN business_objective IS NOT NULL AND business_objective != '' THEN 1
ELSE 0
END as is_relevant,
CASE
WHEN target_date IS NOT NULL THEN 1
ELSE 0
END as is_time_bound
FROM kpi_registry
),
kpi_quality_scores AS (
SELECT
kpi_name,
kpi_category,
measurement_frequency,
data_source,
target_value,
current_value,
-- Calculate SMART score
(is_specific + is_measurable + is_achievable + is_relevant + is_time_bound) * 20 as smart_score,
-- Data quality assessment
CASE
WHEN last_updated >= CURRENT_DATE - INTERVAL '7 days' THEN 100
WHEN last_updated >= CURRENT_DATE - INTERVAL '30 days' THEN 80
WHEN last_updated >= CURRENT_DATE - INTERVAL '90 days' THEN 60
ELSE 40
END as data_freshness_score,
-- Performance assessment
CASE
WHEN current_value >= target_value THEN 100
WHEN current_value >= target_value * 0.8 THEN 80
WHEN current_value >= target_value * 0.6 THEN 60
ELSE 40
END as performance_score
FROM kpi_definitions
),
kpi_recommendations AS (
SELECT
kpi_name,
kpi_category,
smart_score,
data_freshness_score,
performance_score,
-- Overall quality score
(smart_score + data_freshness_score + performance_score) / 3 as overall_quality_score,
-- Recommendations for improvement
CASE
WHEN smart_score < 80 THEN 'Refine KPI definition using SMART framework'
ELSE NULL
END as smart_recommendation,
CASE
WHEN data_freshness_score < 80 THEN 'Improve data collection and update frequency'
ELSE NULL
END as data_recommendation,
CASE
WHEN performance_score < 60 THEN 'Review targets and improvement strategies'
ELSE NULL
END as performance_recommendation
FROM kpi_quality_scores
)
SELECT
'KPI Quality Assessment' as assessment_type,
kpi_name,
kpi_category,
ROUND(smart_score, 0) as smart_score,
ROUND(data_freshness_score, 0) as data_score,
ROUND(performance_score, 0) as performance_score,
ROUND(overall_quality_score, 0) as overall_score,
CASE
WHEN overall_quality_score >= 80 THEN 'Excellent KPI'
WHEN overall_quality_score >= 60 THEN 'Good KPI'
WHEN overall_quality_score >= 40 THEN 'Average KPI'
ELSE 'Poor KPI - Needs Revision'
END as kpi_quality_rating,
COALESCE(smart_recommendation, '') || ' ' || COALESCE(data_recommendation, '') || ' ' || COALESCE(performance_recommendation, '') as improvement_recommendations
FROM kpi_recommendations
ORDER BY overall_quality_score DESC;
Scorecards
Dashboards
| Characteristic | Scorecards | Dashboards |
|---|---|---|
| Primary Purpose | Performance evaluation | Operational monitoring |
| Time Orientation | Historical (periodic) | Real-time/continuous |
| Visual Style | Tabular, structured | Charts, graphs, visual |
| Interactivity | Limited | High (filters, drill-downs) |
| Update Frequency | Monthly/quarterly | Real-time/daily |
| Target Focus | Yes (vs targets) | No (trends/patterns) |
| Audience | Executives | Analysts/Operators |
Executive Scorecard
-- Executive scorecard with target comparisons
WITH executive_kpis AS (
SELECT
kpi_name,
kpi_category,
current_value,
target_value,
previous_period_value,
-- Performance calculations
CASE
WHEN target_value > 0 THEN (current_value / target_value - 1) * 100
ELSE NULL
END as target_achievement_pct,
CASE
WHEN previous_period_value > 0 THEN (current_value / previous_period_value - 1) * 100
ELSE NULL
END as period_change_pct,
-- Status indicators
CASE
WHEN current_value >= target_value THEN 'On Target'
WHEN current_value >= target_value * 0.9 THEN 'Slightly Below Target'
WHEN current_value >= target_value * 0.8 THEN 'Below Target'
ELSE 'Critical'
END as target_status,
CASE
WHEN period_change_pct >= 10 THEN 'Strong Improvement'
WHEN period_change_pct >= 5 THEN 'Improvement'
WHEN period_change_pct >= 0 THEN 'Stable'
WHEN period_change_pct >= -5 THEN 'Slight Decline'
ELSE 'Declining'
END as trend_status,
-- RAG rating (Red-Amber-Green)
CASE
WHEN target_achievement_pct >= 100 THEN 'Green'
WHEN target_achievement_pct >= 90 THEN 'Amber'
ELSE 'Red'
END as rag_rating
FROM kpi_performance
WHERE kpi_level = 'Executive'
AND reporting_period = '2024-Q3'
),
scorecard_summary AS (
SELECT
kpi_category,
COUNT(*) as total_kpis,
COUNT(CASE WHEN rag_rating = 'Green' THEN 1 END) as green_kpis,
COUNT(CASE WHEN rag_rating = 'Amber' THEN 1 END) as amber_kpis,
COUNT(CASE WHEN rag_rating = 'Red' THEN 1 END) as red_kpis,
ROUND(AVG(target_achievement_pct), 1) as avg_achievement,
ROUND(AVG(period_change_pct), 1) as avg_change
FROM executive_kpis
GROUP BY kpi_category
)
SELECT
'Executive Scorecard' as report_type,
kpi_name,
kpi_category,
ROUND(current_value, 2) as current_value,
ROUND(target_value, 2) as target_value,
ROUND(target_achievement_pct, 1) as achievement_pct,
ROUND(period_change_pct, 1) as change_pct,
target_status,
trend_status,
rag_rating as status,
CASE
WHEN rag_rating = 'Green' THEN '✓ On Track'
WHEN rag_rating = 'Amber' THEN '⚠ Attention Needed'
ELSE '✗ Action Required'
END as action_required
FROM executive_kpis
UNION ALL
SELECT
'Category Summary' as report_type,
kpi_category as kpi_name,
'Summary' as kpi_category,
total_kpis as current_value,
green_kpis as target_value,
ROUND(avg_achievement, 1) as achievement_pct,
ROUND(avg_change, 1) as change_pct,
CASE
WHEN avg_achievement >= 100 THEN 'On Target'
WHEN avg_achievement >= 90 THEN 'Slightly Below Target'
ELSE 'Below Target'
END as target_status,
CASE
WHEN avg_change >= 5 THEN 'Improving'
WHEN avg_change >= 0 THEN 'Stable'
ELSE 'Declining'
END as trend_status,
CASE
WHEN avg_achievement >= 100 THEN 'Green'
WHEN avg_achievement >= 90 THEN 'Amber'
ELSE 'Red'
END as status,
CASE
WHEN avg_achievement >= 100 THEN '✓ Category Performing Well'
WHEN avg_achievement >= 90 THEN '⚠ Category Needs Attention'
ELSE '✗ Category Requires Action'
END as action_required
FROM scorecard_summary
ORDER BY
CASE kpi_category WHEN 'Summary' THEN 1 ELSE 2 END,
kpi_category,
kpi_name;
Operational Dashboard
-- Real-time operational dashboard metrics
WITH operational_metrics AS (
SELECT
-- Sales metrics
COUNT(DISTINCT CASE WHEN order_date = CURRENT_DATE THEN order_id END) as today_orders,
COUNT(DISTINCT CASE WHEN order_date >= CURRENT_DATE - INTERVAL '7 days' THEN order_id END) as week_orders,
SUM(CASE WHEN order_date = CURRENT_DATE THEN order_total END) as today_revenue,
SUM(CASE WHEN order_date >= CURRENT_DATE - INTERVAL '7 days' THEN order_total END) as week_revenue,
-- Customer metrics
COUNT(DISTINCT CASE WHEN last_login = CURRENT_DATE THEN customer_id END) as active_users_today,
COUNT(DISTINCT CASE WHEN last_login >= CURRENT_DATE - INTERVAL '7 days' THEN customer_id END) as active_users_week,
COUNT(DISTINCT CASE WHEN signup_date = CURRENT_DATE THEN customer_id END) as new_users_today,
-- Website metrics
SUM(CASE WHEN visit_date = CURRENT_DATE THEN page_views END) as page_views_today,
SUM(CASE WHEN visit_date >= CURRENT_DATE - INTERVAL '7 days' THEN page_views END) as page_views_week,
AVG(CASE WHEN visit_date = CURRENT_DATE THEN session_duration END) as avg_session_today,
-- Support metrics
COUNT(CASE WHEN ticket_created = CURRENT_DATE THEN ticket_id END) as tickets_today,
COUNT(CASE WHEN ticket_created >= CURRENT_DATE - INTERVAL '7 days' THEN ticket_id END) as tickets_week,
AVG(CASE WHEN ticket_created >= CURRENT_DATE - INTERVAL '7 days' THEN resolution_hours END) as avg_resolution_week,
-- Inventory metrics
COUNT(CASE WHEN stock_level <= reorder_point THEN product_id END) as low_stock_items,
COUNT(CASE WHEN stock_level = 0 THEN product_id END) as out_of_stock_items
FROM operational_data
),
trend_analysis AS (
SELECT
-- Calculate trends and comparisons
today_orders,
LAG(today_orders, 1) OVER (ORDER BY CURRENT_DATE) as yesterday_orders,
today_revenue,
LAG(today_revenue, 1) OVER (ORDER BY CURRENT_DATE) as yesterday_revenue,
active_users_today,
LAG(active_users_today, 1) OVER (ORDER BY CURRENT_DATE) as yesterday_active_users,
-- Calculate day-over-day changes
CASE
WHEN LAG(today_orders, 1) OVER (ORDER BY CURRENT_DATE) > 0 THEN
(today_orders - LAG(today_orders, 1) OVER (ORDER BY CURRENT_DATE)) * 100.0 / LAG(today_orders, 1) OVER (ORDER BY CURRENT_DATE)
ELSE NULL
END as orders_dod_change,
CASE
WHEN LAG(today_revenue, 1) OVER (ORDER BY CURRENT_DATE) > 0 THEN
(today_revenue - LAG(today_revenue, 1) OVER (ORDER BY CURRENT_DATE)) * 100.0 / LAG(today_revenue, 1) OVER (ORDER BY CURRENT_DATE)
ELSE NULL
END as revenue_dod_change
FROM operational_metrics
),
alert_conditions AS (
SELECT
metric_name,
current_value,
threshold_value,
CASE
WHEN current_value > threshold_value THEN 'Above Threshold'
WHEN current_value < threshold_value THEN 'Below Threshold'
ELSE 'Normal'
END as alert_status,
CASE
WHEN metric_name = 'Low Stock Items' AND current_value > 10 THEN 'Critical'
WHEN metric_name = 'Avg Resolution Time' AND current_value > 24 THEN 'Critical'
WHEN metric_name = 'Page Views Today' AND current_value < 1000 THEN 'Warning'
ELSE 'Normal'
END as alert_level
FROM (
SELECT 'Low Stock Items' as metric_name, low_stock_items as current_value, 5 as threshold_value
FROM operational_metrics
UNION ALL
SELECT 'Avg Resolution Time' as metric_name, avg_resolution_week as current_value, 12 as threshold_value
FROM operational_metrics
UNION ALL
SELECT 'Page Views Today' as metric_name, page_views_today as current_value, 5000 as threshold_value
FROM operational_metrics
) alert_data
)
SELECT
'Sales Metrics' as metric_category,
'Today Orders' as metric_name,
today_orders as current_value,
yesterday_orders as previous_value,
ROUND(orders_dod_change, 1) as change_pct,
CASE
WHEN orders_dod_change > 10 THEN '📈 Strong Growth'
WHEN orders_dod_change > 0 THEN '📊 Growth'
WHEN orders_dod_change > -10 THEN '📉 Slight Decline'
ELSE '📉 Significant Decline'
END as trend_indicator
FROM trend_analysis
UNION ALL
SELECT
'Sales Metrics' as metric_category,
'Today Revenue' as metric_name,
ROUND(today_revenue, 2) as current_value,
ROUND(yesterday_revenue, 2) as previous_value,
ROUND(revenue_dod_change, 1) as change_pct,
CASE
WHEN revenue_dod_change > 15 THEN '📈 Strong Growth'
WHEN revenue_dod_change > 0 THEN '📊 Growth'
WHEN revenue_dod_change > -15 THEN '📉 Slight Decline'
ELSE '📉 Significant Decline'
END as trend_indicator
FROM trend_analysis
UNION ALL
SELECT
'Customer Metrics' as metric_category,
'Active Users Today' as metric_name,
active_users_today as current_value,
yesterday_active_users as previous_value,
ROUND((active_users_today - yesterday_active_users) * 100.0 / NULLIF(yesterday_active_users, 0), 1) as change_pct,
CASE
WHEN active_users_today > yesterday_active_users * 1.1 THEN '👥 Growing'
WHEN active_users_today >= yesterday_active_users * 0.9 THEN '👥 Stable'
ELSE '👥 Declining'
END as trend_indicator
FROM trend_analysis
UNION ALL
SELECT
'Alert Metrics' as metric_category,
metric_name,
current_value,
threshold_value as previous_value,
NULL as change_pct,
CASE
WHEN alert_level = 'Critical' THEN '🚨 ' || alert_status
WHEN alert_level = 'Warning' THEN '⚠️ ' || alert_status
ELSE '✅ ' || alert_status
END as trend_indicator
FROM alert_conditions
ORDER BY
CASE metric_category
WHEN 'Alert Metrics' THEN 1
WHEN 'Sales Metrics' THEN 2
ELSE 3
END,
metric_name;
Internal Benchmarking
Competitive Benchmarking
Functional Benchmarking
Generic Benchmarking
Internal Benchmarking
-- Internal benchmarking - comparing current performance against historical baselines
WITH historical_benchmarks AS (
SELECT
-- Calculate historical baselines
metric_name,
AVG(CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as baseline_2023,
AVG(CASE WHEN period BETWEEN '2022-01-01' AND '2022-12-31' THEN value END) as baseline_2022,
STDDEV(CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as stddev_2023,
-- Calculate percentiles for benchmark ranges
PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as p25_2023,
PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as p50_2023,
PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as p75_2023,
PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY CASE WHEN period BETWEEN '2023-01-01' AND '2023-12-31' THEN value END) as p90_2023
FROM performance_metrics
WHERE period >= '2022-01-01'
GROUP BY metric_name
),
current_performance AS (
SELECT
metric_name,
value as current_value,
period as current_period
FROM performance_metrics
WHERE period = '2024-10-01' -- Current period
),
benchmark_comparison AS (
SELECT
hb.metric_name,
hb.baseline_2023,
hb.baseline_2022,
hb.stddev_2023,
hb.p25_2023,
hb.p50_2023,
hb.p75_2023,
hb.p90_2023,
cp.current_value,
-- Performance vs benchmarks
(cp.current_value - hb.baseline_2023) / hb.baseline_2023 * 100 as vs_baseline_2023_pct,
(cp.current_value - hb.baseline_2022) / hb.baseline_2022 * 100 as vs_baseline_2022_pct,
-- Statistical significance (z-score)
(cp.current_value - hb.baseline_2023) / NULLIF(hb.stddev_2023, 0) as z_score,
-- Percentile ranking
CASE
WHEN cp.current_value >= hb.p90_2023 THEN 'Top 10%'
WHEN cp.current_value >= hb.p75_2023 THEN 'Top 25%'
WHEN cp.current_value >= hb.p50_2023 THEN 'Above Average'
WHEN cp.current_value >= hb.p25_2023 THEN 'Below Average'
ELSE 'Bottom 25%'
END as percentile_ranking
FROM historical_benchmarks hb
JOIN current_performance cp ON hb.metric_name = cp.metric_name
)
SELECT
'Internal Benchmarking' as benchmark_type,
metric_name,
ROUND(current_value, 2) as current_value,
ROUND(baseline_2023, 2) as baseline_2023,
ROUND(vs_baseline_2023_pct, 1) as vs_baseline_2023_pct,
ROUND(z_score, 2) as z_score,
percentile_ranking,
CASE
WHEN ABS(z_score) > 2 THEN 'Statistically Significant'
WHEN ABS(z_score) > 1 THEN 'Notable Difference'
ELSE 'Normal Variation'
END as statistical_significance,
CASE
WHEN vs_baseline_2023_pct > 10 THEN 'Significant Improvement'
WHEN vs_baseline_2023_pct > 5 THEN 'Moderate Improvement'
WHEN vs_baseline_2023_pct > 0 THEN 'Slight Improvement'
WHEN vs_baseline_2023_pct > -5 THEN 'Slight Decline'
WHEN vs_baseline_2023_pct > -10 THEN 'Moderate Decline'
ELSE 'Significant Decline'
END as performance_trend
FROM benchmark_comparison
ORDER BY vs_baseline_2023_pct DESC;
Competitive Benchmarking
-- Competitive benchmarking - comparing against industry standards
WITH industry_benchmarks AS (
SELECT
metric_name,
industry_average,
industry_top_quartile,
industry_median,
industry_bottom_quartile,
data_source,
last_updated
FROM competitive_intelligence
WHERE industry = 'E-commerce'
AND last_updated >= '2024-01-01'
),
company_performance AS (
SELECT
metric_name,
current_value,
previous_year_value
FROM company_metrics
WHERE reporting_period = '2024-Q3'
),
competitive_analysis AS (
SELECT
ib.metric_name,
ib.industry_average,
ib.industry_top_quartile,
ib.industry_median,
ib.industry_bottom_quartile,
cp.current_value,
cp.previous_year_value,
-- Competitive positioning
(cp.current_value - ib.industry_average) / ib.industry_average * 100 as vs_industry_avg_pct,
(cp.current_value - ib.industry_median) / ib.industry_median * 100 as vs_industry_median_pct,
-- Market position calculation
CASE
WHEN cp.current_value >= ib.industry_top_quartile THEN 'Leader (Top 25%)'
WHEN cp.current_value >= ib.industry_median THEN 'Above Average'
WHEN cp.current_value >= ib.industry_bottom_quartile THEN 'Below Average'
ELSE 'Laggard (Bottom 25%)'
END as market_position,
-- Competitive gap analysis
ib.industry_top_quartile - cp.current_value as gap_to_leader,
CASE
WHEN ib.industry_top_quartile > 0 THEN
(ib.industry_top_quartile - cp.current_value) / ib.industry_top_quartile * 100
ELSE NULL
END as gap_to_leader_pct
FROM industry_benchmarks ib
JOIN company_performance cp ON ib.metric_name = cp.metric_name
)
SELECT
'Competitive Benchmarking' as benchmark_type,
metric_name,
ROUND(current_value, 2) as company_value,
ROUND(industry_average, 2) as industry_avg,
ROUND(industry_top_quartile, 2) as industry_top_quartile,
ROUND(vs_industry_avg_pct, 1) as vs_industry_pct,
market_position,
ROUND(gap_to_leader, 2) as gap_to_leader,
ROUND(gap_to_leader_pct, 1) as gap_to_leader_pct,
CASE
WHEN market_position = 'Leader (Top 25%)' THEN '🏆 Market Leader'
WHEN market_position = 'Above Average' THEN '📈 Strong Performer'
WHEN market_position = 'Below Average' THEN '📊 Room for Improvement'
ELSE '⚠️ Needs Significant Improvement'
END as competitive_status,
-- Strategic recommendations
CASE
WHEN gap_to_leader_pct > 20 THEN 'Major strategic initiative required'
WHEN gap_to_leader_pct > 10 THEN 'Focused improvement program needed'
WHEN gap_to_leader_pct > 5 THEN 'Continuous improvement focus'
ELSE 'Maintain leadership position'
END as strategic_recommendation
FROM competitive_analysis
ORDER BY gap_to_leader_pct DESC;
Functional Benchmarking
-- Functional benchmarking - comparing specific processes across industries
WITH functional_benchmarks AS (
SELECT
business_function,
process_name,
industry,
best_in_class_performance,
best_practice_description,
implementation_complexity,
potential_improvement_pct
FROM functional_benchmark_database
WHERE data_quality = 'High'
AND last_verified >= '2024-01-01'
),
company_processes AS (
SELECT
business_function,
process_name,
current_performance,
current_maturity_level,
annual_process_cost
FROM company_process_metrics
WHERE assessment_date = '2024-09-01'
),
benchmark_opportunities AS (
SELECT
fb.business_function,
fb.process_name,
fb.industry as best_practice_industry,
fb.best_in_class_performance,
fb.best_practice_description,
fb.implementation_complexity,
fb.potential_improvement_pct,
cp.current_performance,
cp.current_maturity_level,
cp.annual_process_cost,
-- Improvement potential
(fb.best_in_class_performance - cp.current_performance) / cp.current_performance * 100 as improvement_potential_pct,
(fb.best_in_class_performance - cp.current_performance) / cp.current_performance * cp.annual_process_cost as annual_value_potential,
-- Priority scoring
(fb.potential_improvement_pct * 0.4 +
CASE fb.implementation_complexity WHEN 'Low' THEN 100 WHEN 'Medium' THEN 70 WHEN 'High' THEN 40 END * 0.3 +
annual_value_potential / 1000000 * 0.3) as priority_score
FROM functional_benchmarks fb
JOIN company_processes cp ON fb.business_function = cp.business_function
AND fb.process_name = cp.process_name
WHERE fb.best_in_class_performance > cp.current_performance
)
SELECT
'Functional Benchmarking' as benchmark_type,
business_function,
process_name,
best_practice_industry,
ROUND(current_performance, 2) as current_performance,
ROUND(best_in_class_performance, 2) as best_in_class,
ROUND(improvement_potential_pct, 1) as improvement_potential_pct,
ROUND(annual_value_potential, 0) as annual_value_potential,
implementation_complexity,
current_maturity_level,
ROUND(priority_score, 0) as priority_score,
CASE
WHEN priority_score >= 80 THEN '🚀 High Priority - Quick Win'
WHEN priority_score >= 60 THEN '📈 Medium Priority - Strategic'
WHEN priority_score >= 40 THEN '📋 Low Priority - Consider'
ELSE '⏸️ Defer - Low Impact'
END as implementation_priority,
-- Implementation recommendations
CASE
WHEN implementation_complexity = 'Low' AND improvement_potential_pct > 20 THEN 'Implement immediately'
WHEN implementation_complexity = 'Medium' AND improvement_potential_pct > 30 THEN 'Plan for next quarter'
WHEN implementation_complexity = 'High' AND improvement_potential_pct > 50 THEN 'Major initiative - Plan carefully'
ELSE 'Evaluate business case'
END as implementation_timeline
FROM benchmark_opportunities
ORDER BY priority_score DESC;
1. Data Quality Assurance
2. Context Consideration
3. Continuous Improvement
4. Strategic Alignment
In the next lesson, we'll explore data governance and lineage to understand how to ensure data quality and traceability in business intelligence systems.