-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added statistics model, updated revenue model
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ config(materialized='table') }} | ||
|
||
with trips_data as ( | ||
select * from {{ ref('fact_trips') }} | ||
) | ||
select | ||
-- Reveneue grouping | ||
pickup_zone as revenue_zone, | ||
date_trunc('month', pickup_datetime) as revenue_month, | ||
--Note: For BQ use instead: date_trunc(pickup_datetime, month) as revenue_month, | ||
|
||
service_type, | ||
|
||
-- Additional calculations | ||
count(tripid) as total_monthly_trips, | ||
avg(passenger_count) as avg_montly_passenger_count, | ||
avg(trip_distance) as avg_montly_trip_distance | ||
|
||
from trips_data | ||
group by 1,2,3 | ||
|