SQL Interview Prep - Day 4

Pareto Principle (80/20 Rule)

What is Pareto Principle ?

The Pareto Principle, also known as the 80/20 Rule, states that roughly 80% of the effects come from 20% of the causes. In simpler terms, a small portion of inputs or efforts tends to contribute the majority of the results or outcomes. This principle is observed in various fields, such as business, economics, and time management, suggesting that focusing on the most significant factors can lead to the most significant impact.

Example:

  • 80% of the productivity come from 20% of the employees.

  • 80% of your sales come from 20% of your clients

  • 80% of decisions in a meeting are made in 20% of the time

  • 80% of sales come from 20% of your product services

Problem Statement

Based on the principle we would be finding the sales of the product which is 80% comes from your product 20% then it satisfy the pareto principle.

From the list of the products we would need to find the top products contributing in the top 20% and resulting 80% of the sales.

Approach

1) Find the sale for each product

2) Get the 80% of the sales

3) Now we will do running total in order to find the top products that will be contributing to the 80% sales

Sample output for the above running over total

4) Now we will also add the column for 80% of total_sales and try to match the product that matched the 80%

Here all the product till row 413 are top products that matches the 80% of total sales

5) Check whether 413 products contributes to 20% of products giving 80% of total sales

6) To list the around 20% products that are contributing to 80% sales

Output Snippet: