TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst · 76.7K subscribers
Post #2663 1.98K
WITH ranked_videos AS (
    SELECT
        video_title,
        category,
        views,
        ROW_NUMBER() OVER (
            PARTITION BY category
            ORDER BY views DESC
        ) AS rn
    FROM videos
)
SELECT
    video_title,
    category,
    views
FROM ranked_videos
WHERE rn = 1;


💡 Example 4: Calculate Channel Performance 
SELECT
    c.channel_name,
    COUNT(v.video_id) AS total_videos,
    SUM(v.views) AS total_views,
    SUM(v.likes) AS total_likes,
    SUM(v.comments) AS total_comments
FROM channels c
LEFT JOIN videos v
    ON c.channel_id = v.channel_id
GROUP BY c.channel_name
ORDER BY total_views DESC;

💡 Example 5: Analyze Publishing Performance 
SELECT
    EXTRACT(DOW FROM publish_date) AS day_of_week,
    COUNT(*) AS total_videos,
    ROUND(AVG(views), 0) AS avg_views
FROM videos
GROUP BY EXTRACT(DOW FROM publish_date)
ORDER BY avg_views DESC;

💡 Example 6: Rank Videos by Views 
SELECT
    video_title,
    views,
    DENSE_RANK() OVER (
        ORDER BY views DESC
    ) AS view_rank
FROM videos;

🎯 Key Insights You Can Derive

🔹 Which videos generate the most views? 
🔹 Which content categories perform best? 
🔹 Which videos have high engagement but relatively low views? 
🔹 What publishing days generate the most views? 
🔹 Which channels have the strongest audience engagement? 
🔹 Which content contributes most to subscriber growth? 
🔹 Which videos should be promoted further? 

💼 This project is especially useful for Data Analysts, Product Analysts, Growth Analysts, Marketing Analysts, and Business Intelligence professionals working with content, media, and digital platforms.

Double Tap ❤️ For More
  • ❤ 6
More from @sqlanalyst
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026SQL Interview Series — Part 4 📌 Question 4: Find the Highest Salary in Each Department Su…
  3. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  4. Sep 29, 2026SQL Interview Series — Part 2 📌 Question 2: Find Duplicate Records Suppose you have an Em…
  5. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  6. Sep 29, 2026SQL Interview Series — Part 1 Hi guys, let's start a SQL interview series covering frequen…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →