Skip to content

Commit

Permalink
Added statistics model, updated revenue model
Browse files Browse the repository at this point in the history
  • Loading branch information
clkao committed Feb 22, 2023
1 parent 38b3ef7 commit a38f6ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions models/core/dm_monthly_zone_revenue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ with trips_data as (
sum(congestion_surcharge) as revenue_monthly_congestion_surcharge,

-- Additional calculations
count(tripid) as total_monthly_trips,
avg(passenger_count) as avg_montly_passenger_count,
avg(trip_distance) as avg_montly_trip_distance
-- 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
21 changes: 21 additions & 0 deletions models/core/dm_monthly_zone_statistics.sql
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

0 comments on commit a38f6ce

Please sign in to comment.