-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_code.txt
42 lines (20 loc) · 952 Bytes
/
sql_code.txt
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
SELECT
T.id AS "Trip ID"
, T.duration AS "Duration"
, TO_CHAR(T.start_date, "MM/DD/YYYY HH24:MI") AS "Start Date"
, DS.terminal_name AS "Start Terminal"
, DS.station_name AS "Start Station"
, TO_CHAR(T.end_date, "MM/DD/YYYY HH24:MI") AS "End Date"
, S.station_name AS "End Station"
, S.terminal_name AS "End Terminal"
, DN.entity_name AS "Bike #"
, DN.entity_type AS "Subscriber Type"
, ZIP.zip_code AS "Zip Code"
FROM
fact_trips T
INNER JOIN dim_stations DS ON T.start_station_id = DS.id
INNER JOIN dim_stations S ON T.end_station_id = S.id
INNER JOIN dim_entity DN ON T.entity_id = DN.id
INNER JOIN dim_entity_zip ZIP ON ZIP.entity_id = DN.id
WHERE T.start_date >= TO_TIMESTAMP("03-01-2014 00:00:00", "MM-DD-YYYY HH24:MI:SS")
AND T.start_date <= TO_TIMESTAMP("08-31-2014 23:59:59", "MM-DD-YYYY HH24:MI:SS");