fix mistakes with cohort analysis
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
CREATE MATERIALIZED VIEW user_cohort_analysis AS
|
CREATE MATERIALIZED
|
||||||
|
VIEW user_cohort_analysis AS
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
TO_CHAR(pu.cohort_month, 'YYYY-MM') AS MONTH,
|
TO_CHAR(pu.cohort_month, 'YYYY-MM') AS MONTH,
|
||||||
@@ -6,7 +7,8 @@ CREATE MATERIALIZED VIEW user_cohort_analysis AS
|
|||||||
COUNT(DISTINCT pe.user_id) AS enrolled_users,
|
COUNT(DISTINCT pe.user_id) AS enrolled_users,
|
||||||
COUNT(DISTINCT plv.user_id) AS active_users,
|
COUNT(DISTINCT plv.user_id) AS active_users,
|
||||||
ROUND(COUNT(DISTINCT plv.user_id) * 100.0 / COUNT(DISTINCT pu.id), 2) || '%' AS retention_rate,
|
ROUND(COUNT(DISTINCT plv.user_id) * 100.0 / COUNT(DISTINCT pu.id), 2) || '%' AS retention_rate,
|
||||||
ROUND(AVG((SELECT COUNT(*) FROM pet_courses pc)) / COUNT(DISTINCT pu.id), 2) AS avg_courses_per_user,
|
ROUND(AVG((SELECT COUNT(pe.id)
|
||||||
|
FROM pet_enrollments pe)) / COUNT(DISTINCT pu.id), 2) AS avg_courses_per_user,
|
||||||
(SELECT
|
(SELECT
|
||||||
ROUND(AVG(table_first_viewed_at.first_viewed_at::date - pu2.registration_date::date), 2)
|
ROUND(AVG(table_first_viewed_at.first_viewed_at::date - pu2.registration_date::date), 2)
|
||||||
FROM pet_users pu2
|
FROM pet_users pu2
|
||||||
|
|||||||
Reference in New Issue
Block a user