This repository has been archived on 2025-12-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
click-house/queries/analize.sql
2025-11-26 23:53:20 +06:00

48 lines
1.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ### ✅ **Задание 5: Напиши SQL-запросы к витринам**
-- **Напиши свои вариации для практики.**
-- 📌 *Ниже — примеры.*
-- ### Топ-5 самых просматриваемых уроков
-- SELECT
-- lesson_title,
-- course_title,
-- total_views
-- FROM lesson_popularity_summary
-- ORDER BY total_views DESC
-- LIMIT 5;
SELECT *
FROM (
SELECT * FROM pet_project.mv_lesson_popularity_summary
) AS top_lessons
LIMIT 5
;
WITH selected_top AS (SELECT *
FROM pet_project.mv_lesson_popularity_summary)
SELECT *
FROM selected_top
LIMIT 5
;
-- ### Неактивные пользователи, записавшиеся на курсы
-- SELECT
-- name,
-- email,
-- registered_courses_count
-- FROM inactive_users_summary
-- WHERE registered_courses_count > 0
-- ORDER BY registration_date DESC;
-- дальше по аналогии как ВЫШЕ, подзапрос или CTE
-- ### Курсы с самым высоким процентом завершения
-- SELECT
-- course_title,
-- AVG(completion_rate) AS avg_completion
-- FROM course_completion_rate
-- GROUP BY course_title
-- ORDER BY avg_completion DESC
-- LIMIT 5;
-- дальше по аналогии как ВЫШЕ, подзапрос или CTE