Skip to content

SQL projects using the different functions from basic to advance

License

Notifications You must be signed in to change notification settings

ellaclauz/SQL-FOR-DATA-ANALYSIS

Repository files navigation

SQL-FOR-DATA-ANALYSIS

warehouse

PostgreSQL project for analyzing warehouse and retail sales with the following questions.

  • what is the total retail sales for each supplier?

QUERY:

select supplier, sum(retailsales) as total_retail_sales
from project 
group by supplier;

RESULT:

supply

  • what is the total retail sales for each combination of supplier and month

QUERY:

select supplier, year, month, sum(retailsales) as total_retail_sales
from project 
group by supplier, year, month;

RESULT:

S2

  • what is the maximum warehouse sales for each item description?

QUERY:

select itemdescription, max(retailsales) as max_warehouse_sales
from project 
group by itemdescription;

RESULT:

S3

  • what is the average retail transfer for each year

QUERY:

select year, avg(retailtransfers) as avg_retail_transfers
from project 
group by year;

RESULT:

S4

  • for each item description, what is the difference between the maximum and minimum retail sales? QUERY:
select itemdescription, max(retailsales) - min(retailsales) as diff_max_min_retail_sales
from project 
group by itemdescription;

RESULT:

S5

  • what is the total retail sales for each supplier, broken down by year and month

QUERY:

select year, month, supplier,
       sum(retailsales) over (partition by supplier, year, month) as total_retail_sales
from project;

RESULT: S6

  • what is the running total of retail sales for each item type, order by month? QUERY:
select year, month, itemtype,
       sum(retailsales) over (partition by itemtype order by month) as running_total_retail_sales
from project;

RESULT:

S7

  • what is the difference in retail sales between each month and the previous month, for each supplier and item type? QUERY:
select year, month, supplier, itemtype,
       retailsales - lag(retailsales) over (partition by supplier, itemtype order by year, month) as diff_retail_sales
from project; 

RESULT:

S8

  • what is the average retail sales for each item type compared to the overall average retail sales across all item types for each year?
  • What is the percentage of retail sales for each supplier, compared to the total retail sales across all suppliers, broken down by year and month?
  • What is the month with the highest retail transfer for each supplier, for the past 12 months?

NOTE: This is just a sample of the query and results

About

SQL projects using the different functions from basic to advance

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published