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);