pushing back
This commit is contained in:
parent
8de993ddba
commit
f911912b45
2 changed files with 16 additions and 12 deletions
13
models/intermediate/int_core__guest_fee_txns.sql
Normal file
13
models/intermediate/int_core__guest_fee_txns.sql
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
with
|
||||
monster_payment_join as (
|
||||
select vtp.*, vpt.*, p.*, ps."Name"
|
||||
from sync_core."VerificationToPayment" vtp
|
||||
left join
|
||||
sync_core."VerificationPaymentType" vpt
|
||||
on vtp."VerificationPaymentTypeId" = vpt."Id"
|
||||
left join sync_core."Payment" p on vtp."PaymentId" = p."PaymentId"
|
||||
left join sync_core."PaymentStatus" ps on p."PaymentStatusId" = ps."Id"
|
||||
where vpt."Name" = 'Fee'
|
||||
)
|
||||
select cast("PaymentDueDate" as date) as paymenent_due_at_utc, "Amount" as amount
|
||||
from monster_payment_join
|
||||
|
|
@ -1,18 +1,9 @@
|
|||
with
|
||||
date_master as (select * from {{ ref("int_dates") }}),
|
||||
fee_txns as (
|
||||
select vtp.*, vpt.*, p.*, ps."Name"
|
||||
from sync_core."VerificationToPayment" vtp
|
||||
left join
|
||||
sync_core."VerificationPaymentType" vpt
|
||||
on vtp."VerificationPaymentTypeId" = vpt."Id"
|
||||
left join sync_core."Payment" p on vtp."PaymentId" = p."PaymentId"
|
||||
left join sync_core."PaymentStatus" ps on p."PaymentStatusId" = ps."Id"
|
||||
where vpt."Name" = 'Fee'
|
||||
)
|
||||
select date_day, sum("Amount")
|
||||
fee_txns as (select * from {{ ref("int_core__guest_fee_txns") }})
|
||||
select date_master.date_day, coalesce(sum(fee_txns.amount), 0)
|
||||
from date_master
|
||||
left join fee_txns on date_master.date_day = cast(fee_txns."PaymentDueDate" as date)
|
||||
left join fee_txns on date_master.date_day = fee_txns.paymenent_due_at_utc
|
||||
where date_day between '2022-01-01' and '2024-12-31'
|
||||
group by date_master.date_day
|
||||
order by 2 desc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue