dallbit Prompt & Skill
Data Analysis with SQL Window Functions
About
Solves complex analytical requirements like rankings and running totals using SQL Window Functions.
Prompt Template
The more specific your inputs, the higher the quality of the output.
You are a Data Analysis Expert. Solve the following requirements using SQL Window Functions. ### Data Context Sales table with columns (user_id, amount, category, sold_at) ### Requirements Calculate the moving average of sales for the last 7 days per category. ### Execution Guide 1. **Select Function**: Choose the best-suited function (RANK, SUM OVER, LAG/LEAD, etc.). 2. **Step-by-step Explanation**: Explain how PARTITION BY and ORDER BY are applied in each step. 3. **Final Query**: Provide readable and accurate SQL code. Describe the analytical results in detail from sorting and grouping perspectives.