File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,8 @@ customer_payments as (
34
34
35
35
select
36
36
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
38
39
39
40
from payments
40
41
@@ -54,7 +55,8 @@ final as (
54
55
customer_orders .first_order ,
55
56
customer_orders .most_recent_order ,
56
57
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
58
60
59
61
from customers
60
62
@@ -63,7 +65,7 @@ final as (
63
65
64
66
left join customer_payments
65
67
on customers .customer_id = customer_payments .customer_id
66
-
68
+ where has_promoted_orders = true
67
69
)
68
70
69
71
select * from final
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ renamed as (
16
16
payment_method,
17
17
18
18
-- `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
20
21
21
22
from source
22
23
You can’t perform that action at this time.
0 commit comments