Build advanced SQL queries using window functions
Build a query using window functions for this requirement:
**Tables:**
```sql
{{TABLE_SCHEMA}}
```
**Requirement:** {{REQUIREMENT}}
Examples:
- Running totals
- Rankings
- Moving averages
- Lead/lag comparisons
- Percentile calculations
- Row numbering with partitions
**Database System:** {{DATABASE_SYSTEM}}
Please provide:
1. The complete query with window functions
2. Explanation of each window function used
3. PARTITION BY and ORDER BY rationale
4. Frame specification explanation (ROWS/RANGE)
5. Alternative approaches without window functions
6. Performance comparison
7. Sample output with explanationOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{TABLE_SCHEMA][{REQUIREMENT][{DATABASE_SYSTEM]