Skip to content

Commit

Permalink
Update dim__orgs.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
diveart authored Aug 1, 2024
1 parent b0a45ab commit 167bb2e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions models/core_/dim__orgs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WITH orgs AS (
, user_count AS (
SELECT
org_id
, count(distinct user_id) + case when random() > 0.5 then 1 else 0 end AS num_users
, count(distinct user_id) + mod(org_id, 2) AS num_users
FROM {{ ref('user__created') }}
GROUP BY 1
)
Expand All @@ -28,18 +28,18 @@ WITH orgs AS (
org_id
, event_timestamp AS sub_created_at
, plan as sub_plan
, price as sub_price
, price
FROM {{ ref('subscription__created') }}
)


SELECT
orgs.org_id
case when mod(orgs.org_id, 49) = 0 then orgs.org_id - 50000000 else orgs.org_id end as org_id
, created_at
, num_users
, sub_created_at
, sub_plan
, sub_price
, case when num_users <= 1 then 'Individual' else sub_plan end as sub_plan
, coalesce(price, 0) as sub_price
FROM orgs
LEFT JOIN user_count on orgs.org_id = user_count.org_id
LEFT JOIN subscriptions on orgs.org_id = subscriptions.org_id

0 comments on commit 167bb2e

Please sign in to comment.