大会员生效开始日期在’2021-9-1‘和‘2021-9-31’日之间并且没在‘2021-9-1’之前出现过的不重复用户的个数即为9月份新会员的人数。

SELECT count(distinct user_id) as new_cnt

FROM detail_list_tb

WHERE begin_date BETWEEN '2021-9-1' AND '2021-9-30'

AND user_id NOT IN

(

SELECT user_id from detail_list_tb

WHERE begin_date<'2021-9-1'

);