PET project task 3 completed
This commit is contained in:
@@ -272,4 +272,22 @@ create materialized view course_summary AS
|
||||
order by course_id
|
||||
;
|
||||
|
||||
--------------------------------------------------------------------------------------------------
|
||||
-- 3 задание Общая отчетность по взаимодействию
|
||||
create materialized view platform_summary as
|
||||
with total_counts as (
|
||||
select COUNT(id) as total_users,
|
||||
(select COUNT(id) from courses) as total_courses,
|
||||
(select COUNT(id) from lessons) as total_lessons,
|
||||
(select COUNT(id) from lesson_views) as total_views,
|
||||
(select COUNT(distinct user_id) from lesson_views) as users_with_views
|
||||
from users
|
||||
)
|
||||
SELECT total_users, total_courses, total_lessons, users_with_views,
|
||||
ROUND(1.00 * total_lessons / total_courses, 2) as avg_lessons_per_course,
|
||||
ROUND(1.00 * total_views / total_lessons, 2) as avg_views_per_lesson
|
||||
from total_counts
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user