-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analysis1.cs
45 lines (33 loc) · 1.1 KB
/
Analysis1.cs
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
/**
Extract Trip Data
**/
@TripData =
EXTRACT [Trip ID] string,
[Duration] int,
[Start Date] DateTime,
[Start Terminal] int,
[End Date] DateTime,
[End Terminal] int,
[Bike #] int,
[Subscriber Type] string,
[Zip Code] string
FROM "/Input/201508_trip_data.csv"
USING Extractors.Csv(skipFirstNRows : 1);
// Question 1: Top 20 zip codes where most bikes were rented from.
@TransformedData =
SELECT [Zip Code], SUM([Bike #]) AS TotalRides
FROM @TripData
GROUP BY [Zip Code];
OUTPUT @TransformedData
TO "/Output/trial_Q1.csv"
ORDER BY TotalRides DESC
FETCH 20 ROWS
USING Outputters.Csv(outputHeader : true);
//Question 2: Daily duration aggregate across the rental subscriber types
@Tranform2 =
SELECT [Subscriber Type],[Start Date].ToString("dd/MM/yyyy") AS DateOnly,SUM([Duration]) AS TotalDuration
FROM @TripData
GROUP BY [Start Date].ToString("dd/MM/yyyy"),[Subscriber Type];
OUTPUT @Tranform2
TO "/Output/trial_Q2.csv"
USING Outputters.Csv(outputHeader : true);