405. Pareto Principle (80/20 Rule)

Hard Consulting Advanced Analytics
Query Rules
  • The query columns and order must match the expected result schema.
  • NULL values should be handled appropriately where applicable.
  • The grader compares output values and sorting order to evaluate.

Schema Browser

Click a table's header to toggle expand/collapse.
locations
3 cols
departments
3 cols
employees
6 cols
orders
6 cols

Reference Solution

Expected SQL
WITH cat_sales AS (SELECT product_category, SUM(amount) AS revenue FROM orders GROUP BY product_category), total_sales AS (SELECT SUM(revenue) as global_total FROM cat_sales) SELECT product_category, revenue, SUM(revenue) OVER (ORDER BY revenue DESC) * 100.0 / (SELECT global_total FROM total_sales) AS cumulative_pct FROM cat_sales;
SQL Editor
Ctrl+Enter to run
Console Output

Console Terminal

Write your query and click "Run Query" (Ctrl + Enter) to see results and testcase validation.