Skip to content

Analytical Sql -windows functions- Simple project

Notifications You must be signed in to change notification settings

maraimmarco/Analytical-SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Analytical SQL PROJECT

OVERVIEW

This project comprises a series of SQL queries aimed at analyzing business data to derive valuable insights for decision-making and strategic planning. The queries cover various aspects of business operations, including revenue analysis, sales trends, customer segmentation, and customer purchase patterns.

QUERIES REVIEW

1. First Query: Total Revenue by Customer

  • Objective: Calculate the total revenue generated by each customer.
  • SQL Query: Utilizes aggregation functions to sum the product of quantity and price for each customer.
  • Implementation: Provides insights into individual customer contributions to overall revenue.

2. Monthly Sales Trend

  • Objective: Analyze revenue trends over time by breaking down sales data into monthly increments.
  • SQL Query: Utilizes substr and sum functions to aggregate sales data by month.
  • Implementation: Offers a comprehensive overview of sales performance on a month-by-month basis.

3. Top Selling Products

  • Objective: Identify the best-performing products by aggregating the total quantity sold for each stock code.
  • SQL Query: Uses sum and order by functions to rank products based on total quantity sold.
  • Implementation: Uncovers top-selling products driving profitability and customer satisfaction.

4. Customer Purchase Frequency

  • Objective: Understand customer purchasing habits by calculating the total number of unique invoices per customer.
  • SQL Query: Utilizes count and distinct functions to count the number of unique invoices for each customer.
  • Implementation: Provides insights into customer loyalty and engagement for targeted marketing strategies.

5. Average Order Value

  • Objective: Calculate the average order value to optimize sales strategies.
  • SQL Query: Summarizes the total value of each invoice (order) using the sum function.
  • Implementation: Offers insights into customer spending patterns and transactional behaviors.

6. The Most Frequent Product Sold in Each Country

  • Objective: Identify the most popular products in each country to understand international sales trends.
  • SQL Query: Utilizes window functions and subqueries to analyze sales data by country and stock code.
  • Implementation: Reveals cross-border preferences and market trends.

7. Analyzing Sales Trends Using Lag

  • Objective: Delve into sales dynamics over time using sophisticated lag functions.
  • SQL Query: Examines changes in quantity sold relative to previous transactions to identify patterns and fluctuations.
  • Implementation: Provides insights into demand fluctuations across different product categories and regions.

Customer Segmentation

  • Objective: Implement a Monetary model for customer behavior and segment customers based on specific groups.
  • Implementation: Utilizes RFM (Recency, Frequency, Monetary) model to segment customers and offers targeted marketing strategies.

Analysis of Customer Purchase Patterns

  • Objective: Analyze customer purchase patterns by identifying the maximum consecutive days between purchases for each customer.
  • Implementation: Utilizes SQL queries to gain insights into customer activity and loyalty.

Query Purpose

  • Objective: Calculate the average number of days it takes for customers to reach a spending threshold of 250 units or more from their first purchase date.
  • Implementation: Utilizes Common Table Expressions (CTEs) and main query to derive insights into customer spending behavior.

Expected Outcome

The expected outcome of running these SQL queries is to obtain valuable insights into various aspects of business operations, including revenue analysis, sales trends, customer behavior, and purchase patterns. These insights can then be used for decision-making, strategic planning, and targeted marketing efforts.

About

Analytical Sql -windows functions- Simple project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages