From a18691b96038b94ef1caa90c9605cceb9b005732 Mon Sep 17 00:00:00 2001 From: mary435 Date: Tue, 28 Feb 2023 12:41:52 -0300 Subject: [PATCH] make some model changes --- models/core/dm_monthly_zone_revenue.sql | 6 +++--- models/core/dm_monthly_zone_statistics.sql | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 models/core/dm_monthly_zone_statistics.sql diff --git a/models/core/dm_monthly_zone_revenue.sql b/models/core/dm_monthly_zone_revenue.sql index 6d92df4f..b1a97cb5 100644 --- a/models/core/dm_monthly_zone_revenue.sql +++ b/models/core/dm_monthly_zone_revenue.sql @@ -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 diff --git a/models/core/dm_monthly_zone_statistics.sql b/models/core/dm_monthly_zone_statistics.sql new file mode 100644 index 00000000..ee9043c6 --- /dev/null +++ b/models/core/dm_monthly_zone_statistics.sql @@ -0,0 +1,20 @@ +{{ 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 \ No newline at end of file