how to – mySQL – Date Difference and Flags
I am very new to mySQL and currently working on a table with three columns: trx_id, user_id, last_activity. (Churn Analysis)
tbl_activity:
The table capture activity of users. I am finding it difficulty in performing two tasks.
1) I would like to see two new columns through SQL query
- date difference between subsequent transactions.
- flag based on condition > 30 days.
desired table:
2) One of the objectives of this study is to identify when (date) a customer churned. Ideally in my case it would be the 31st day since last activity. Any way to arrive at this date?
I am new to SQL learning and finding it difficult to address SQL queries for the above tasks. Thank you in advance.
Source: Stackoverflow
Recent Comments