fixed reltive last comments

This commit is contained in:
SERGEY_KONEV
2025-12-27 17:41:27 +03:00
parent ebc2f07fc8
commit 207c435477
2 changed files with 7 additions and 7 deletions
@@ -6,11 +6,12 @@
CREATE MATERIALIZED VIEW IF NOT EXISTS dm.lesson_popularity_summary AS
-- EXPLAIN ANALYZE
DISTRIBUTED BY (lesson_id, course_id)
WITH t1 AS (
SELECT
lesson_id,
course_id,
COUNT(lesson_id) AS total_views,
COUNT(*) AS total_views,
COUNT(DISTINCT user_id) AS unique_users,
MIN(viewed_at)AS first_view,
MAX(viewed_at)AS last_view
@@ -25,8 +26,8 @@ SELECT
c.title AS course_title
FROM core.dim_course c
LEFT JOIN core.dim_lesson l USING(course_id)
)
SELECT
t1.lesson_id,
t2.lesson_title,
@@ -37,6 +38,5 @@ SELECT
t1.first_view,
t1.last_view
FROM t1
LEFT JOIN t2 USING(lesson_id)
LEFT JOIN t2 USING(lesson_id, course_id);
DISTRIBUTED BY (lesson_id, course_id);
@@ -7,6 +7,7 @@
CREATE MATERIALIZED VIEW IF NOT EXISTS dm.inactive_users_summary AS
-- EXPLAIN ANALYZE
DISTRIBUTED BY (user_id)
WITH t1 AS (
SELECT
user_id,
@@ -19,10 +20,9 @@ SELECT
u.name AS user_name,
u.email,
u.age,
coalesce(t1.enrollments_count, 0),
coalesce(t1.enrollments_count, 0) AS enrollments_count,
u.registration_date
FROM core.dim_user u
LEFT JOIN t1 USING (user_id)
WHERE u.user_id NOT IN (SELECT user_id FROM core.fact_lesson_views)
WHERE u.user_id NOT EXISTS (SELECT user_id FROM core.fact_lesson_views);
DISTRIBUTED BY (user_id);