-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperstore_SQL_Analysis.sql
More file actions
83 lines (70 loc) · 1.89 KB
/
Copy pathSuperstore_SQL_Analysis.sql
File metadata and controls
83 lines (70 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- ===========================================
-- Superstore SQL Analysis Project
-- Database: superstore
-- Table: superstore_data
-- ===========================================
USE superstore;
-- 1. Total Sales
SELECT SUM(Sales) AS Total_Sales
FROM superstore_data;
-- 2. Total Profit
SELECT SUM(Profit) AS Total_Profit
FROM superstore_data;
-- 3. Top 10 Products by Sales
SELECT `Product Name`, SUM(Sales) AS Total_Sales
FROM superstore_data
GROUP BY `Product Name`
ORDER BY Total_Sales DESC
LIMIT 10;
-- 4. Top 10 Customers by Sales
SELECT `Customer Name`, SUM(Sales) AS Total_Sales
FROM superstore_data
GROUP BY `Customer Name`
ORDER BY Total_Sales DESC
LIMIT 10;
-- 5. Most Profitable State
SELECT State, SUM(Profit) AS Total_Profit
FROM superstore_data
GROUP BY State
ORDER BY Total_Profit DESC
LIMIT 10;
-- 6. Average Sales by Region
SELECT Region, AVG(Sales) AS Average_Sales
FROM superstore_data
GROUP BY Region
ORDER BY Average_Sales DESC;
-- 7. Least Profitable Products
SELECT `Product Name`, SUM(Profit) AS Total_Profit
FROM superstore_data
GROUP BY `Product Name`
ORDER BY Total_Profit ASC
LIMIT 10;
-- 8. Most Profitable Products
SELECT `Product Name`, SUM(Profit) AS Total_Profit
FROM superstore_data
GROUP BY `Product Name`
ORDER BY Total_Profit DESC
LIMIT 10;
-- 9. Top 10 Cities by Sales
SELECT City, SUM(Sales) AS Total_Sales
FROM superstore_data
GROUP BY City
ORDER BY Total_Sales DESC
LIMIT 10;
-- 10. Top 10 Sub Categories by Sales
SELECT `Sub Category`, SUM(Sales) AS Total_Sales
FROM superstore_data
GROUP BY `Sub Category`
ORDER BY Total_Sales DESC
LIMIT 10;
-- 11. Customers with the Most Orders
SELECT `Customer Name`, COUNT(`Order ID`) AS Total_Orders
FROM superstore_data
GROUP BY `Customer Name`
ORDER BY Total_Orders DESC
LIMIT 10;
-- 12. Category with Highest Average Profit
SELECT Category, AVG(Profit) AS Average_Profit
FROM superstore_data
GROUP BY Category
ORDER BY Average_Profit DESC;