MEDIUMAI Generated Practice• Data Analyst
Customer Churn Preceding Event
Verified Source:AI Generated Practice (Groq Llama 3.3)
(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_idlast_actioncancel_time
Order by user_id ascending.
Table:
customer_audit(audit_idINT,user_idINT,action_nameVARCHAR,action_timeTIMESTAMP)
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(7 lines, 110 chars)
Tab Indent⌘↵ Run Query
Ready to execute. Press Run (⌘+Enter)
Write your query and click “Run” or press ⌘+Enter to inspect output.