🏠 Accueil
Benchmarks
📊 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 📖 Glossaire IA 🔗 Liens Utiles
Advanced

Complex SQL Window Functions

#sql #data-analysis #optimization

Solve a complex data retrieval problem using advanced window functions and CTEs.

Given a dataset of sales transactions including transaction_id, user_id, amount, and timestamp, write a PostgreSQL query to calculate the 3-day moving average of sales per user alongside the user's total sales amount up to but not including the current transaction date. Use Common Table Expressions (CTEs) for clarity and window functions for frame calculation. Provide an explanation of how the frame clause affects the calculation.