🏠 Startseite
Vergleiche
📊 Alle Benchmarks 🦖 Dinosaurier v1 🦖 Dinosaurier v2 ✅ To-Do-Listen-Apps 🎨 Kreative freie Seiten 🎯 FSACB - Ultimatives Showcase 🌍 Übersetzungs-Benchmark
Modelle
🏆 Top 10 Modelle 🆓 Kostenlose Modelle 📋 Alle Modelle ⚙️ Kilo Code
Ressourcen
💬 Prompt-Bibliothek 📖 KI-Glossar 🔗 Nützliche Links
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.