MEDIUMAI Generated Practice• Data Analyst

Customer Churn Preceding Event

(AI Generated Practice Question — Generated by Groq Llama 3.3 and validated by PGlite engine)

A subscription company wants to analyze user activity right before they cancel their membership.

For each user who has a cancel_subscription event, find the most recent event they performed prior to canceling. Output:

  • user_id
  • last_action
  • cancel_time

Order by user_id ascending.

Table:

  • customer_audit (audit_id INT, user_id INT, action_name VARCHAR, action_time TIMESTAMP)

Execution Sandbox:

Your query executes inside an isolated in-memory PostgreSQL engine (PGlite WebAssembly). You have full access to standard PostgreSQL aggregations, window functions, and CTEs.

Standard SQL (ANSI)|Ln 1, Col 1
⌘↵ Run Query
Ready to execute. Press Run (⌘+Enter)
Write your query and click “Run” or press ⌘+Enter to inspect output.