🏠 Trang chủ
Benchmark
📊 Tất cả benchmark 🦖 Khủng long v1 🦖 Khủng long v2 ✅ Ứng dụng To-Do List 🎨 Trang tự do sáng tạo 🎯 FSACB - Trình diễn cuối cùng 🌍 Benchmark dịch thuật
Mô hình
🏆 Top 10 mô hình 🆓 Mô hình miễn phí 📋 Tất cả mô hình ⚙️ Kilo Code
Tài nguyên
💬 Thư viện prompt 📖 Thuật ngữ AI 🔗 Liên kết hữu ích
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.