我很难将查询限制为只计算与csv字符串的所有部分匹配的项目。我当前的查询运行但似乎只计算csv中列出的元素之一,而不是计算与csv匹配的所有活动。我注意到,当我将这些值分开时,有些空格而其他则没空,但我不知道如何解决。
select (sum (kept)/60)
from (select distinct sa.staff_id, sa.service_date, sa.client_id, sa.actual_duration as kept
from rpt_scheduled_activities as sa
inner join rpt_staff_performance_target as spt
on sa.staff_id = spt.staff_id
where (sa.status = 'Kept'
and sa.service_date between '01-nov-2014' and '30-nov-2014'
and sa.activity_name in
(select regexp_split_to_table(spt.activity,',')
from rpt_staff_performance_target as spt))
) as p
感谢您的考虑以及您可以提供的任何提示!!