Customer Retention and Churn Analysis | Part 2 | SQL Intermediate Question 6

Поделиться
HTML-код
  • Опубликовано: 26 ноя 2024

Комментарии •

  • @Naveen-uz4hw
    @Naveen-uz4hw 5 месяцев назад

    select distinct cust_id
    from
    (select *
    ,min(order_date) over(partition by cust_id order by order_date) as min_date
    ,max(order_date) over(partition by cust_id order by order_date desc) as max_date
    from transactions)a
    where (month(max_date)-month(min_date))=1

  • @nidhisingh4973
    @nidhisingh4973 7 месяцев назад

    Thank you. Do you think this will work for not consecutive month order date and different year order date. Suppose cust_id 1 has ordered in Jan, Feb and May. So ideally this id should come for Feb churn analysis but this will not come with this solution approach.
    Please correct me if I am wrong.