union all暴力解题简单思路(跳过处理空值步骤直接分组求和,最后汇总个数即可):

with tmp as(

    select count(case when course like '%course1%' then 1 else NULL end) as course_nums

    from cultivate_tb

    union all

    select count(case when course like '%course2%' then 1 else NULL end) as course_nums

    from cultivate_tb

    union all

    select count(case when course like '%course3%' then 1 else NULL end) as course_nums

    from cultivate_tb

)

select sum(course_nums) as staff_nums

from tmp