SQL Query Generation

ChatGPT📝 TextOct 26, 2025max_prompt

About this result

Get complex queries written correctly the first time. No syntax errors, no missing edge cases — just copy, paste, run.

ChatGPT Prompt

Act as a Database Administrator. Write a PostgreSQL query for the following request.

Schema Context:

  • Table 'users' (id, email, signup_date)
  • Table 'orders' (id, user_id, amount, status, created_at)

Goal: Find the top 10% of users by total spend (LTV) who signed up in the last 12 months, but haven't purchased anything in the last 30 days (churn risk).

Constraints:

  • Use Common Table Expressions (CTEs) for readability.
  • Exclude 'refunded' status orders.
  • Format the output code for readability.
#data#sql#database

Was this prompt helpful?

6

people found this useful

M

max_prompt

Shared Oct 26, 2025

Have a great prompt to share?

Submit Your Prompt