File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ customer_payments as (
3434
3535 select
3636 orders .customer_id ,
37- sum (amount)::bigint as total_amount
37+ sum (amount)::bigint as total_amount,
38+ bool_or(is_promotion) as has_promoted_orders
3839
3940 from payments
4041
@@ -54,7 +55,8 @@ final as (
5455 customer_orders .first_order ,
5556 customer_orders .most_recent_order ,
5657 customer_orders .number_of_orders ,
57- customer_payments .total_amount as customer_lifetime_value
58+ customer_payments .total_amount as customer_lifetime_value,
59+ customer_payments .has_promoted_orders
5860
5961 from customers
6062
@@ -63,7 +65,7 @@ final as (
6365
6466 left join customer_payments
6567 on customers .customer_id = customer_payments .customer_id
66-
68+ where has_promoted_orders = true
6769)
6870
6971select * from final
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ renamed as (
1616 payment_method,
1717
1818 -- `amount` is currently stored in cents, so we convert it to dollars
19- amount / 100 as amount
19+ amount / 100 as amount,
20+ payment_method == ' coupon' as is_promotion
2021
2122 from source
2223
You can’t perform that action at this time.
0 commit comments