🏠 Accueil
基準測試
📊 Tous les Benchmarks 🦖 Dinosaure v1 🦖 Dinosaure v2 ✅ To-Do List Apps 🎨 Pages Libres 🎯 FSACB - Showcase 🌍 Traduction
Modèles
🏆 Top 10 Modèles 🆓 Modèles Gratuits 📋 Tous les Modèles ⚙️ Modes Kilo Code
Ressources
💬 Prompts IA 📖 人工智能詞彙表 🔗 Liens Utiles
advanced

Complex Time-Series Analysis with SQL

#sql #data-analysis #window-functions

Solve a retention analysis problem using advanced window functions.

Write a SQL query to calculate the cohort retention rate for a subscription service. The input is a table of user logs (user_id, log_date, action). Your query must calculate the percentage of users who return in the 1st, 2nd, and 3rd months after their initial signup. Use window functions such as LAG, LEAD, and FIRST_VALUE to achieve this without using self-joins. Handle the scenario where a user churns and returns, ensuring they are counted based on their latest cohort.