Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cnolanminich/bb1d8fd7738dbc6c4f1c320486a378fb to your computer and use it in GitHub Desktop.

Select an option

Save cnolanminich/bb1d8fd7738dbc6c4f1c320486a378fb to your computer and use it in GitHub Desktop.
high velocity credits for current POC customers / dagster+ customers
with daily as(
select
ds::date as reporting_date,
sum(standard_credits) as daily_standard_credits,
sum(high_velocity_credits) as daily_high_velo_credits,
daily_standard_credits + daily_high_velo_credits as total_credits_daily
from purina.product.usage_metrics_daily
where usage_metrics_daily.organization_id = {org_id here}
group by ds::date
)
select
date_trunc('week', reporting_date) as reporting_week,
sum(daily_standard_credits) as weekly_standard_credits,
sum(daily_high_velo_credits) as weekly_high_velo_credits,
sum(total_credits_daily) as weekly_total_credits,
weekly_high_velo_credits / weekly_total_credits * 100 as percent_high_velo
from daily
group by reporting_week
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment