-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorporate_actions_queries.sql
More file actions
49 lines (41 loc) · 1.22 KB
/
Copy pathcorporate_actions_queries.sql
File metadata and controls
49 lines (41 loc) · 1.22 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
-- Use the corporateactions database
USE corporateactions;
-- Explore the dataset
SELECT * FROM Corporate_Actions_Data LIMIT 10;
SELECT COUNT(*) AS TotalRows FROM Corporate_Actions_Data;
-- Create reusable Views
-- 1. Total Events
CREATE VIEW v_total_events AS
SELECT COUNT(*) AS TotalEvents
FROM Corporate_Actions_Data;
-- 2. Events by Country
CREATE VIEW v_events_by_country AS
SELECT Country, COUNT(*) AS EventCount
FROM Corporate_Actions_Data
GROUP BY Country
ORDER BY EventCount DESC;
-- 3. Monthly Trend
CREATE VIEW v_monthly_trend AS
SELECT DATE_FORMAT(Announcement_Date, "%Y-%m") AS MonthYear,
COUNT(*) AS EventCount
FROM Corporate_Actions_Data
GROUP BY MonthYear
ORDER BY MonthYear;
-- 4. Top Sectors
CREATE VIEW v_top_sectors AS
SELECT Sector, COUNT(*) AS EventCount
FROM Corporate_Actions_Data
GROUP BY Sector
ORDER BY EventCount DESC
LIMIT 5;
-- 5. Event Types
CREATE VIEW v_event_types AS
SELECT Event_Type, COUNT(*) AS EventCount
FROM Corporate_Actions_Data
GROUP BY Event_Type
ORDER BY EventCount DESC;
-- Market Cap Split (supporting query)
SELECT Market_Cap_Category, COUNT(*) AS EventCount
FROM Corporate_Actions_Data
GROUP BY Market_Cap_Category
ORDER BY EventCount DESC;