-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinancial_Analytics_SQL.sql
More file actions
111 lines (89 loc) · 2.45 KB
/
Copy pathFinancial_Analytics_SQL.sql
File metadata and controls
111 lines (89 loc) · 2.45 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
select * from financial_data;
-- 1 Total Net Revenue, Total Expense, Total Profit, and Profit Margin
select
round(sum(Net_Revenue),2) as Total_Revenue,
round(sum(Total_Expense),2) as Total_Expense,
round(sum(Profit),2) as Total_Profit,
round((sum(Profit) / SUM(Net_Revenue)) * 100, 2) AS Profit_Margin_Percentage
FROM financial_data;
-- 2 Monthly revenue and profit trend
select
Year,
Month,
round(sum(Net_Revenue),2) Monthly_Revenue,
round(sum(Profit),2) Monthly_Profit
from financial_data
group by Year, Month
order by Year, Month;
-- 3 Top 5 products by revenue
select
Product,
round(sum(Net_Revenue),2) Total_Revenue
from financial_data
group by Product
order by Total_Revenue desc
limit 5;
-- 4 Profit by UAE region
select
Region,
round(sum(Profit),2) Total_Profit
from financial_data
group by Region
order by Total_Profit desc;
-- 5 Customer segment wise revenue and profit
select
Customer_Segment,
round(sum(Net_Revenue),2) Total_Revenue,
round(sum(Profit),2) Total_Profit
from financial_data
group by Customer_Segment
order by Total_Profit desc;
-- 6 Payment status count and overdue revenue
select
Payment_Status,
count(*) Total_Transaction,
ROUND(SUM(Net_Revenue), 2) AS Total_Revenue
from financial_data
group by Payment_Status
order by Total_Revenue desc;
-- 6.1 Only Overdue status
select
Payment_Status,
round(sum(Net_Revenue),2) Total_Revenue
from financial_data
where Payment_Status = 'overdue';
-- 7 Budget vs actual revenue and variance by month
select
Year,
Month,
round(sum(Budget_Target), 2) Budget_Revenue,
round(sum(Net_Revenue), 2) Actual_Revenue,
round(sum(Net_Revenue)- sum(Budget_Target), 2) Variance
from financial_data
group by Year, Month
order by Year, Month;
-- 8 Department wise expense and profit
select
Department,
round(sum(Total_Expense), 2) Total_Expense,
round(sum(Profit), 2) Total_Profit
from financial_data
group by Department
order by Total_Profit desc;
-- 9 Quarter wise revenue growth
select
Year,
Quarter,
round(sum(Net_Revenue), 2) Total_Revenue
from financial_data
group by Year, Quarter
order by Year, Quarter;
-- 10 Find high revenue but low profit margin products
select
Product,
round(sum(Net_Revenue), 2) Total_revenue,
round(sum(Profit), 2) Total_profit,
round((sum(Profit) / sum(Net_Revenue)) * 100, 2) Profit_Margin_Percentage
from financial_data
group by Product
order by Profit_Margin_Percentage asc;