🏠 Accueil
基準測試
📊 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 📖 人工智能詞彙表 🔗 Liens Utiles
advanced

Complex Time-Series Analysis with SQL Window Functions

#sql #database #data-analysis

Solve a data retrieval problem requiring intricate calculation over sliding windows and frame clauses.

Given a table 'stock_prices' with columns 'symbol', 'trade_date', and 'close_price', write a single SQL query that calculates the 30-day moving average, the exponential moving average with a smoothing factor of 0.2, and the Bollinger Bands (upper and lower) for each symbol. The query should return only dates where the closing price crosses above the upper Bollinger Band. Assume a standard PostgreSQL environment. Explain the choice of window frame clauses (RANGE vs. ROWS) and their impact on handling missing dates in the data.