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 690d32e
Showing 1 changed file with 21 additions and 0 deletions.
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 690d32e

Please sign in to comment.