-
Notifications
You must be signed in to change notification settings - Fork 0
/
analytics_query.sql
33 lines (32 loc) · 1.22 KB
/
analytics_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
CREATE OR REPLACE TABLE `de-projects-395321.Uber_data_project.tbl_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-projects-395321.Uber_data_project.fact_table` f
JOIN `de-projects-395321.Uber_data_project.datetime_dim` d ON f.datetime_id=d.datetime_id
JOIN `de-projects-395321.Uber_data_project.passenger_count_dim` p ON p.passenger_count_id=f.passenger_count_id
JOIN `de-projects-395321.Uber_data_project.trip_distance_dim` t ON t.trip_distance_id=f.trip_distance_id
JOIN `de-projects-395321.Uber_data_project.rate_code_dim` r ON r.rate_code_id=f.rate_code_id
JOIN `de-projects-395321.Uber_data_project.pickup_location_dim` pick ON pick.pickup_location_id=f.pickup_location_id
JOIN `de-projects-395321.Uber_data_project.dropoff_location_dim` drop ON drop.dropoff_location_id=f.dropoff_location_id
JOIN `de-projects-395321.Uber_data_project.payment_type_dim` pay ON pay.payment_type_id=f.payment_type_id)
;