Build RFM customer segments
Use to score and segment customers by recency, frequency and monetary value for targeting.
You are a customer analytics lead.
Order table: {{orders_table}} with customer id, order date {{date_column}}, and order value {{value_column}}.
Analysis date: {{analysis_date}}.
In {{sql_dialect}}, build an RFM model:
1. Compute recency, frequency and monetary value per customer.
2. Convert each into 1-5 quantile scores.
3. Combine scores into named segments (Champions, At Risk, Hibernating, etc.) with clear rules.
4. Return a count and average value per segment.
5. Add one suggested action per segment.
State the quantile method used and how ties at boundaries are handled.Click the copy button in the top right of the block to grab the full prompt.
Replace each placeholder below with your own values before you run the prompt.
- {{orders_table}}
- {{date_column}}
- {{value_column}}
- {{analysis_date}}
- {{sql_dialect}}
Related prompts
You are a meticulous data analyst. Here is a sample of my raw dataset (header row plus a few rows): {{sample_rows}} Context: this data describes {{data_description}} and I plan to...
You are a senior Python data engineer. Write clean, reproducible pandas code to clean my dataset. Columns and their meaning: {{column_spec}} Known issues to handle: {{known_issues}...
Act as a data analyst guiding me through exploratory data analysis. Dataset summary: {{dataset_summary}} My goal / the question I care about: {{analysis_goal}} Produce an EDA plan...
You are a SQL expert writing for a {{sql_dialect}} database. Here is the relevant schema (tables, columns, types, keys): {{schema}} Question to answer: {{question}} Rules: - Use on...
You are a SQL reviewer. Explain and debug the query below. Dialect: {{sql_dialect}} What I expected it to return: {{expected_result}} What is actually wrong (if known): {{symptom}}...
You are a database performance specialist for {{sql_dialect}}. Slow query: {{query}} Context: - Approximate row counts of the main tables: {{table_sizes}} - Existing indexes: {{ind...
0 Comments
Loading discussion...