From 4ab75887bd65c9d1f18d9e0dd70ed060a15a297f Mon Sep 17 00:00:00 2001 From: gwen windflower <91998347+gwenwindflower@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:06:43 -0500 Subject: [PATCH] mess up column orders --- models/marts/customers.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/models/marts/customers.sql b/models/marts/customers.sql index 129eb8ff..d556d9c1 100644 --- a/models/marts/customers.sql +++ b/models/marts/customers.sql @@ -17,13 +17,13 @@ customer_orders_summary as ( select orders.customer_id, - count(distinct orders.order_id) as count_lifetime_orders, count(distinct orders.order_id) > 1 as is_repeat_buyer, - min(orders.ordered_at) as first_ordered_at, - max(orders.ordered_at) as last_ordered_at, + count(distinct orders.order_id) as count_lifetime_orders, + sum(orders.order_total) as lifetime_spend sum(orders.subtotal) as lifetime_spend_pretax, + min(orders.ordered_at) as first_ordered_at, sum(orders.tax_paid) as lifetime_tax_paid, - sum(orders.order_total) as lifetime_spend + max(orders.ordered_at) as last_ordered_at, from orders @@ -36,12 +36,12 @@ joined as ( select customers.*, - customer_orders_summary.count_lifetime_orders, - customer_orders_summary.first_ordered_at, - customer_orders_summary.last_ordered_at, customer_orders_summary.lifetime_spend_pretax, + customer_orders_summary.count_lifetime_orders, customer_orders_summary.lifetime_tax_paid, customer_orders_summary.lifetime_spend, + customer_orders_summary.first_ordered_at, + customer_orders_summary.last_ordered_at, case when customer_orders_summary.is_repeat_buyer then 'returning'