Skip to content

Commit 799e4fa

Browse files
committed
Add analysis
1 parent 670b5c3 commit 799e4fa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

analysis/amount_by_customer.sql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- analysis/running_total_by_account.sql
2+
3+
with orders as (
4+
5+
select *
6+
from {{ ref('stg_orders') }}
7+
8+
), payments_orders as (
9+
10+
select *
11+
from {{ ref('stg_payments') }}
12+
13+
)
14+
15+
select
16+
orders.customer_id,
17+
order_id,
18+
payment_id,
19+
payment_method,
20+
orders.order_date,
21+
sum(amount_usd) over (partition by orders.customer_id order by order_id rows unbounded preceding)
22+
from payments_orders
23+
right join orders using (order_id)
24+
order by orders.customer_id

0 commit comments

Comments
 (0)