How does this statement tell us if a user is active or not active?


In the context of this exercise, how does this statement tell us if a user is active or not_active?


This statement tells us if a user is active or not active based on conditions.

First, it will check whether the purchase date of the premium plan is earlier than or equal to the current date. If it is not, then there might have been some error or they are not yet signed up.
premium_users.purchase_date <= months.months

Second, it will check whether either of the following conditions is true:

If the user’s cancel date is the current date or is planned for the future, this means that they are still under the plan until their cancel date arrives,
premium_users.cancel_date >= months.months

Or, if the user has no cancel date yet, this means that they did not cancel nor plan to cancel,
premium_users.cancel_date is NULL.

If the first condition and either of the second conditions is true, this must mean they are still active. Otherwise, they are not_active.


Are you Assuming that if he is only active for the “whole month” of January that he is active in January and if not he is not active. This is fallacious reasoning in part cuz if someone is active for even one day during Jan I would consider them active during Jan not inactive.

I agree with board3405145664’s comment!

To rectify i think in the first condition of “premium_users.purchase_date <= months.month”, we could add an or “strftime(“m%”, premium_users.purchase_date) = strftime(”%m", months.month) to also include situations where some users were active for only part of the month or starting not exactly on the first date of month.