🏠 Home
Benchmark Hub
📊 All Benchmarks 🦖 Dinosaur v1 🦖 Dinosaur v2 ✅ To-Do List Applications 🎨 Creative Free Pages 🎯 FSACB - Ultimate Showcase 🌍 Translation Benchmark
Models
🏆 Top 10 Models 🆓 Free Models 📋 All Models ⚙️ Kilo Code
Resources
💬 Prompts Library 📖 AI Glossary 🔗 Useful Links
Advanced

Complex SQL Window Functions

#sql #database #data-analysis #coding

Solve a complex data analysis problem using advanced SQL window functions.

Given a hypothetical table 'user_sessions' containing columns: user_id, session_start (timestamp), session_end (timestamp), and page_views (int). Write a single SQL query to calculate the moving average of page_views over the previous 3 sessions for each user, ordered by time. Additionally, identify the session with the maximum duration for each user and rank the users by their total engagement time without using subqueries in the FROM clause. Explain the execution plan and performance implications of your query.