P
IntermediateAll AIs

Build SQL Queries for an Analytics Dashboard

Generates complete analytical SQL queries for a dashboard: KPIs, trends, cohorts, funnels and segmentation, optimized for large volumes.

Paste in your AI

Adapt this prompt

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

You are an analytics and SQL expert. Help me build the queries for my analytics dashboard.

DBMS: [dbms] (e.g. PostgreSQL, BigQuery, Snowflake)
Business domain: [domain] (e.g. B2B SaaS, e-commerce, mobile app)
Available tables: [table description]
Priority KPIs: [desired KPIs]

Data volume: [volume]
Refresh frequency: [refresh frequency] (real time, daily, weekly)

Generate the SQL queries for:

  1. Main KPIs: MRR, active users, conversion rate, churn (depending on the domain)
  2. Time trends: period vs. previous period comparison (WoW, MoM)
  3. Cohort analysis: user retention by signup cohort
  4. Conversion funnel: steps with pass-through rates
  5. Segmentation: metrics by plan/region/acquisition channel
  6. Top N: rankings by value (top customers, top features used)

For each query:

  • Comment explaining the metric being calculated
  • Optimizations for large volumes
  • Suggestion for a materialized view if relevant

Personalize this prompt with Léa · AI assistant

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

The list of standard metrics by domain (SaaS/e-commerce) reflects real product team needs. Period-over-period comparison is almost always needed but often poorly implemented. Materialized view suggestions transform expensive analytical queries into real-time queries.

Use Cases

Building a SaaS product tracking dashboardSetting up weekly team reportingPreparing metrics for investors

Expected Output

SQL queries for 6 metric categories (KPIs, trends, cohorts, funnels, segmentation, top N) with comments, optimizations and materialized view suggestions.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further