select sum(case when date_format(t.day,'%w') =1 then 1 else 0 end ) as 星期一个数 from (
select date_add('2022-01-01', interval (cast(help_topic_id as signed integer)) day) day
from mysql.help_topic
where help_topic_id < datediff('2022-01-31', '2022-01-01') + 1
order by help_topic_id) t
----------另一种写法------------
select sum(case when dayofweek(t.day)-1 =1 then 1 else 0 end ) as 星期一个数 from (
select date_add('2022-01-01', interval (cast(help_topic_id as signed integer)) day) day
from mysql.help_topic
where help_topic_id < datediff('2022-01-31', '2022-01-01') + 1
order by help_topic_id) t