How can I count changes to columns of the same user_id through passage of time

Viewed 28

The dataset I'm working with contains details of subscriptions.

The table has the following columns user_id, sub_start_date, sub_end_date.

Every time the user_id buys a subscription, the date gets entered to the sub_start_date, and depending on the subscription, the sub_end_date also fills.

I want to count the number of EVENTS where EVENT is defined as the act of renewing your active subscription i.e. renewing it before the sub_end_date passes. I'm just staring at the picture of the table I've drawn on paper. I'm sort of stuck.

I'm working with SQL. Any help would be appreciated.

0 Answers
Related