From 66106b4d052dacb4751779a9b35c9eede3375be2 Mon Sep 17 00:00:00 2001 From: "structuredbot[bot]" <181747078+structuredbot[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:09:05 +0000 Subject: [PATCH 1/2] Update jaffle_shop/models/customer_total_spend.sql [1728583738733] --- jaffle_shop/models/customer_total_spend.sql | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 jaffle_shop/models/customer_total_spend.sql diff --git a/jaffle_shop/models/customer_total_spend.sql b/jaffle_shop/models/customer_total_spend.sql new file mode 100644 index 0000000..d89a9a2 --- /dev/null +++ b/jaffle_shop/models/customer_total_spend.sql @@ -0,0 +1,30 @@ +{{ + config( + materialized='table' + ) +}} + +with orders as ( + select * from {{ ref('stg_orders') }} +), + +customer_spend as ( + select + customer_id, + sum(order_amount) as total_spend + from orders + group by customer_id +), + +customers as ( + select * from {{ ref('stg_customers') }} +) + +select + customers.customer_id, + customers.first_name, + customers.last_name, + coalesce(customer_spend.total_spend, 0) as total_spend +from customers +left join customer_spend using (customer_id) +order by total_spend desc \ No newline at end of file From bdef61a02da4adb24fc76153c20fc78eacb5e45d Mon Sep 17 00:00:00 2001 From: DBT AI Assistant Date: Thu, 10 Oct 2024 18:09:06 +0000 Subject: [PATCH 2/2] Add customer_total_spend model [1728583738733]