-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsql_query.sql
52 lines (52 loc) · 1.39 KB
/
sql_query.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
50
51
52
CREATE OR REPLACE TABLE
`de-uber-project-406317.de_uber_dataset.analytics` AS (
SELECT
f.trip_id,
f.VendorID,
d.tpep_pickup_datetime,
d.tpep_dropoff_datetime,
p.passenger_count,
t.trip_distance,
r.rate_code_name,
pick.pickup_latitude,
pick.pickup_longitude,
drop.dropoff_latitude,
drop.dropoff_longitude,
pay.payment_type_name,
f.fare_amount,
f.extra,
f.mta_tax,
f.tip_amount,
f.tolls_amount,
f.improvement_surcharge,
f.total_amount
FROM
`de-uber-project-406317.de_uber_dataset.fact_table` f
JOIN
`de-uber-project-406317.de_uber_dataset.datetime_dim` d
ON
f.datetime_id=d.datetime_id
JOIN
`de-uber-project-406317.de_uber_dataset.passenger_count_dim` p
ON
p.passenger_count_id=f.passenger_count_id
JOIN
`de-uber-project-406317.de_uber_dataset.trip_distance_dim` t
ON
t.trip_distance_id=f.trip_distance_id
JOIN
`de-uber-project-406317.de_uber_dataset.rate_code_dim` r
ON
r.rate_code_id=f.rate_code_id
JOIN
`de-uber-project-406317.de_uber_dataset.pickup_location_dim` pick
ON
pick.pickup_location_id=f.pickup_location_id
JOIN
`de-uber-project-406317.de_uber_dataset.dropoff_location_dim` DROP
ON
drop.dropoff_location_id=f.dropoff_location_id
JOIN
`de-uber-project-406317.de_uber_dataset.payment_type_dim` pay
ON
pay.payment_type_id=f.payment_type_id) ;