Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH ax AS (
- select
- uid
- from
- stat.funnelTrack
- where
- dt >= today() - INTERVAL '14' DAY
- and action in ('open_parent_activity', 'open')
- AND ((deviceType = 1
- AND appVersion % 2 = 1)
- OR (deviceType = 2
- AND appVersion % 2 = 0))
- GROUP BY
- uid),
- payments AS (
- SELECT
- uid,
- MAX(IF(concat(Type, Value) IN ('subscription_30', 'subscription_365'), 1, 0)) AS SubscriptionPurchase,
- MAX(IF(Sku LIKE '%care_plus%' OR Sku LIKE '%premium%' OR Product Like '%care%', 1, 0)) AS PlusSubscriptionPurchase
- FROM
- analytics.money
- WHERE
- ChargeNumber >= 1
- AND NOT was_refunded
- AND USDNet >= 0.02
- AND ContractCharge_TM >= today() - INTERVAL '13' MONTH
- GROUP BY
- uid
- )
- SELECT
- SubscriptionPurchase,
- PlusSubscriptionPurchase,
- count(*) AS users
- -- uniqCombined(uid) AS uniq,
- -- SUM(SubscriptionPurchase) SubscriptionPurchase,
- -- SUM(PlusSubscriptionPurchase) PlusSubscriptionPurchase
- FROM ax t1 LEFT JOIN payments t2 using(uid)
- GROUP BY 1, 2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement