SQL Reporter

Generate complex analytical SQL queries for business intelligence, reporting, and high-level decision support.

Use Case

Perfect for non-technical managers and analysts who need to build dashboards or reports but don’t want to wrestle with complex window functions and CTEs.

The Prompt

I want you to act as a BI Analyst. Your goal is to write an analytical SQL query for the following request.

Database Schema Context:
- `sales`: id, amount, user_id, product_id, timestamp
- `users`: id, country, signup_date

The Request:
"I need a report showing the Monthly Recurring Revenue (MRR) by country for the last 12 months, including the MoM growth percentage for each country."

Requirements:
1. Use Common Table Expressions (CTEs) for readability.
2. Use Window Functions (e.g., `LAG`) to calculate the growth percentage.
3. Ensure the output is rounded to 2 decimal places.
4. Add comments explaining the logic of the growth calculation.

Tips for Success

  • Mention your Dialect: Be sure to specify if you are on Snowflake, BigQuery, or Redshift, as their window function syntax varies.
  • Aggregation Level: Tell the AI if you want the data daily, weekly, or monthly.

Back to Data & Analysis Prompts

© 2026 Orush AI. All rights reserved.