-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_procedures.sql
More file actions
145 lines (133 loc) · 4.49 KB
/
db_procedures.sql
File metadata and controls
145 lines (133 loc) · 4.49 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use music_db;
drop procedure if exists `track_plays_by_month`;
DELIMITER //
create procedure `track_plays_by_month` (in trc_id int, in days int)
begin
select month(date) as month, sum(amount) as amount from api_trackplaysamount
where trc_id_id=trc_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `track_likes_by_month`;
DELIMITER //
create procedure `track_likes_by_month` (in trc_id int, in days int)
begin
select month(date) as month, count(*) as amount from api_likedtrack
where trc_id_id = trc_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `album_plays_by_month`;
DELIMITER //
create procedure `album_plays_by_month` (in alb_id int, in days int)
begin
select month(date) as month, sum(amount) as amount from api_trackplaysamount
inner join api_track on trc_id_id = api_track.id
where alb_id_id=alb_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `album_likes_by_month`;
DELIMITER //
create procedure `album_likes_by_month` (in alb_id int, in days int)
begin
select month(date) as month, count(*) as amount from api_likedtrack
inner join api_track on trc_id_id = api_track.id
where alb_id_id=alb_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `performer_plays_by_month`;
DELIMITER //
create procedure `performer_plays_by_month` (in per_id int, in days int)
begin
select month(date) as month, sum(amount) as amount from api_trackplaysamount
inner join api_track on trc_id_id = api_track.id
inner join api_album on alb_id_id = api_album.id
where per_id_id=per_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `performer_likes_by_month`;
DELIMITER //
create procedure `performer_likes_by_month` (in per_id int, in days int)
begin
select month(date) as month, count(*) as amount from api_likedtrack
inner join api_track on trc_id_id = api_track.id
inner join api_album on alb_id_id = api_album.id
where per_id_id=per_id and date > now() - interval days day
group by month(date)
order by min(date);
end//
DELIMITER ;
drop procedure if exists `track_plays_by_day`;
DELIMITER //
create procedure `track_plays_by_day` (in trc_id int, in days int)
begin
select min(date) as date, sum(amount) as amount from api_trackplaysamount
where trc_id_id=trc_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;
drop procedure if exists `track_likes_by_day`;
DELIMITER //
create procedure `track_likes_by_day` (in trc_id int, in days int)
begin
select min(date) as date, count(*) as amount from api_likedtrack
where trc_id_id = trc_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;
drop procedure if exists `album_plays_by_day`;
DELIMITER //
create procedure `album_plays_by_day` (in alb_id int, in days int)
begin
select min(date) as date, sum(amount) as amount from api_trackplaysamount
inner join api_track on trc_id_id = api_track.id
where alb_id_id=alb_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;
drop procedure if exists `album_likes_by_day`;
DELIMITER //
create procedure `album_likes_by_day` (in alb_id int, in days int)
begin
select min(date) as date, count(*) as amount from api_likedtrack
inner join api_track on trc_id_id = api_track.id
where alb_id_id=alb_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;
drop procedure if exists `performer_plays_by_day`;
DELIMITER //
create procedure `performer_plays_by_day` (in per_id int, in days int)
begin
select min(date) as date, sum(amount) as amount from api_trackplaysamount
inner join api_track on trc_id_id = api_track.id
inner join api_album on alb_id_id = api_album.id
where per_id_id=per_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;
drop procedure if exists `performer_likes_by_day`;
DELIMITER //
create procedure `performer_likes_by_day` (in per_id int, in days int)
begin
select min(date) as date, count(*) as amount from api_likedtrack
inner join api_track on trc_id_id = api_track.id
inner join api_album on alb_id_id = api_album.id
where per_id_id=per_id and date > now() - interval days day
group by date
order by min(date);
end//
DELIMITER ;