advanced
Complex Natural Language to SQL Translation
Translate a verbose, multi-part analytical question into an optimized SQL query.
📝 프롬프트 내용
Convert the following complex natural language request into a highly optimized PostgreSQL query. The request involves multiple joins, window functions, and conditional aggregation based on a provided schema description: [SCHEMA DESCRIPTION]. Request: 'Calculate the 3-month moving average of sales for each product category, but only include categories where the total sales volume in the previous month was greater than the current month, and rank them by the percentage drop.' Provide the SQL and a brief explanation of the query execution plan.