1

我在一家提供支持的公司工作,我被要求了解如果用户在其工单历史记录中多次看到相同的自动响应,客户满意度评分是否会下降。到目前为止,我已经拉出了不止一次看到相同自动响应或“宏”的用户、宏的名称、他们在工单历史记录中看到它的次数,以及评分和评分:

SELECT user_name,  macro_name, COUNT(*), rating
FROM macros_used m
JOIN cases c
ON c.case_number = m.case_number
join ratings r
on r.case_number = c.case_number
where user_name <> ''
GROUP BY user_name, macro_name
HAVING COUNT(macro_name) > 1

我不确定我是否正确地拉取评级,我可能需要拉取其案例历史和日期中的所有案例以获得每个案例的评级。

我的问题是,有没有办法过滤掉用户第一次看到使用的宏时提供的第一个评级,因为他们第一次看到它,它不会是重复的。我正在尝试查看是否由于重复的宏而导致用户评分下降。

4

1 回答 1

0

您可以使用子查询来查找具有该特定宏的案例的第一个和最后一个评级:

select  cm.*
,       first_rating.rating as first_rating
,       last_rating.rating as last_rating
from    (
        select  c.user_name
        ,       m.macro_name
        ,       count(*) as macro_usage_count
        from    cases c
        join    macros_used m
        on      m.fk_case_number = c.pk_case_number
        group by 
                c.user_name
        ,       m.macro_name
        having  count(m.macro_name) > 1
        ) cm
join    (
        select  r.rating
        from    cases c2
        join    macros_used m2
        on      m2.fk_case_number = c2.pk_case_number
                and c2.user_name = cm.user_name
                and m2.macro_name= cm.macro_name
        join    ratings r2
        on      r2.pk_case_number = c2.case_number
        order by
                r.date_submitted
        limit   1
        ) first_rating
join    (
        select  r.rating
        from    cases c2
        join    macros_used m2
        on      m2.fk_case_number = c2.pk_case_number
                and c2.user_name = cm.user_name
                and m2.macro_name= cm.macro_name
        join    ratings r2
        on      r2.pk_case_number = c2.case_number
        order by
                r.date_submitted desc
        limit   1
        ) last_rating
where   m.user_name <> ''
于 2013-09-25T13:36:23.890 回答