🏠 الرئيسية
المقاييس
📊 جميع المقاييس 🦖 ديناصور v1 🦖 ديناصور v2 ✅ تطبيقات قائمة المهام 🎨 صفحات حرة إبداعية 🎯 FSACB - العرض النهائي 🌍 مقياس الترجمة
النماذج
🏆 أفضل 10 نماذج 🆓 نماذج مجانية 📋 جميع النماذج ⚙️ كيلو كود
الموارد
💬 مكتبة الأوامر 📖 قاموس الذكاء الاصطناعي 🔗 روابط مفيدة
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.