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
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:
- Main KPIs: MRR, active users, conversion rate, churn (depending on the domain)
- Time trends: period vs. previous period comparison (WoW, MoM)
- Cohort analysis: user retention by signup cohort
- Conversion funnel: steps with pass-through rates
- Segmentation: metrics by plan/region/acquisition channel
- 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
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 OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.