🏠 হোম
বেঞ্চমার্ক
📊 সমস্ত বেঞ্চমার্ক 🦖 ডাইনোসর v1 🦖 ডাইনোসর v2 ✅ টু-ডু লিস্ট অ্যাপস 🎨 সৃজনশীল ফ্রি পেজ 🎯 FSACB - চূড়ান্ত শোকেস 🌍 অনুবাদ বেঞ্চমার্ক
মডেল
🏆 সেরা ১০টি মডেল 🆓 ফ্রি মডেল 📋 সমস্ত মডেল ⚙️ কিলো কোড
রিসোর্স
💬 প্রম্পট লাইব্রেরি 📖 এআই গ্লসারি 🔗 দরকারী লিঙ্ক
Advanced

SQL Window Functions Optimization

#sql #database #optimization #analytics

Write a complex SQL query using window functions to calculate moving averages and ranking without self-joins.

Given a sales table with columns (transaction_id, sale_date, amount, region), write a single SQL query that calculates the 3-day moving average of sales per region and ranks each transaction within its region by amount in descending order. Use only window functions (OVER, PARTITION BY, ROWS/RANGE) and avoid using subqueries or self-joins. Optimize for execution on a PostgreSQL database.