-
Notifications
You must be signed in to change notification settings - Fork 2
/
group-traded-volumes.sql
49 lines (45 loc) · 1.29 KB
/
group-traded-volumes.sql
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
SELECT
Year,
COUNT(DISTINCT EVENT_ID) AS Races,
FORMAT(SUM(PPTRADEDVOL),'0.00') as PreVol,
FORMAT(SUM(IPTRADEDVOL),'0.00') as IPvol
FROM [BetfairData].[dbo].[volumes]
group by YEAR
order by YEAR
SELECT
Month,
COUNT(DISTINCT EVENT_ID) AS Races,
FORMAT(SUM(PPTRADEDVOL),'0.00') as PreVol,
FORMAT(SUM(IPTRADEDVOL),'0.00') as IPvol
FROM [BetfairData].[dbo].[volumes]
group by MONTH
order by CASE
WHEN MONTH = 'January' THEN 1
WHEN MONTH = 'February' THEN 2
WHEN MONTH = 'March' THEN 3
WHEN MONTH = 'April' THEN 4
WHEN MONTH = 'May' THEN 5
WHEN MONTH = 'June' THEN 6
WHEN MONTH = 'July' THEN 7
WHEN MONTH = 'August' THEN 8
WHEN MONTH = 'September' THEN 9
WHEN MONTH = 'October' THEN 10
WHEN MONTH = 'November' THEN 11
WHEN MONTH = 'December' THEN 12
END ASC
SELECT
Day,
COUNT(DISTINCT EVENT_ID) AS Races,
FORMAT(SUM(PPTRADEDVOL),'0.00') as PreVol,
FORMAT(SUM(IPTRADEDVOL),'0.00') as IPvol
FROM [BetfairData].[dbo].[volumes]
group by DAY
order by CASE
WHEN Day = 'Monday' THEN 1
WHEN Day = 'Tuesday' THEN 2
WHEN Day = 'Wednesday' THEN 3
WHEN Day = 'Thursday' THEN 4
WHEN Day = 'Friday' THEN 5
WHEN Day = 'Saturday' THEN 6
WHEN Day = 'Sunday' THEN 7
END ASC