Professional Documents
Culture Documents
inbound_type = 2 -- OB
-- and t1.channel_type = 3
and t1.case_id != 0
group by t1.case_id
and MIN(t2.ctime) - MIN(t1.ctime) < 60*60*24*7 --limit for data mart look back period to find
reply
and MIN(t2.ctime) - MIN(t1.ctime) > 0 --to exclude cases where OB came first (else
response time will be neg)
),
reply_time_metric_webform as
,MIN(t1.ctime) as incoming_time
,MIN(t2.ctime) as first_reply_sent_time
from chatbot_data.shopee_seller_cs_case_db__enquiry_tab__my_continuous_s0_live as t1
on t1.case_id = t2.case_id
on case_tab.case_id = t1.case_id
-- and t1.is_first_in_case = 1
and t2.inbound_type = 2 -- OB
-- and t1.channel_type = 3
and t1.case_id != 0
group by t1.case_id
and MIN(t2.ctime) - MIN(t1.ctime) < 60*60*24*7 --limit for data mart look back period to find
reply
and MIN(t2.ctime) - MIN(t1.ctime) > 0 --to exclude cases where OB came first (else
response time will be neg)
),
reply_time_metric as
union
),
special_form_tab as
select enquiry_tab.case_id
-- to get form_type --
on form_tab.id = form_submission_tab.form_id
-- to get case_id --
group by enquiry_tab.case_id
),
case_table as
select case_tab.case_id
,case_tab.user_id as cs_user_id
,case_related_attr_tab.user_type
,case_tab.channel_type
,case_tab.owner_id
,case_tab.enquiry_config_id
,reason_view.l1_name
,reason_view.l2_name
,reason_view.l3_name
-- to get user_type --
left join
chatbot_data.shopee_seller_cs_case_db__case_related_attr_tab__my_continuous_s0_live as
case_related_attr_tab
on case_tab.case_id = case_related_attr_tab.case_id
and case_tab.grass_region = case_related_attr_tab.grass_region
-- to get RCs --
on case_tab.enquiry_config_id = reason_view.l3_id
),
agent_admin as
select account_id
,agent_name
,agent_email
,agent_owner_team
,company_name
,reporting_manager_email
from regops_cs.dim_agent_my_agent_admin_snapshot_di_live
),
queue_table as
,queue_name
,owner_id as queue_owner_id
from chatbot_data.shopee_seller_cs_routing_db__queue_tab__my_continuous_s0_live
where grass_region = '${UDF_REGION}'
and status_flag = 1
),
queue_owner as
,agent_type_name as queue_owner_team
from chatbot_data.shopee_seller_cs_account_db__agent_type_tab__my_continuous_s0_live
and status_flag = 1
),
init_owner as
select case_id
,initial_owner_id
from regops_cs.dwd_rep_my_cs_kpi_shopee_case_initial_owner_di_live
),
initial_owner as
select case_table.case_id
on case_table.case_id = init_owner.case_id
),
initial_owner_details as
select case_id
,agent_name as initial_owner_agent_name
,agent_email as initial_owner_agent_email
,agent_owner_team as initial_owner_agent_owner_team
from initial_owner
select
reply_table.case_id
,reply_table.incoming_time
,reply_table.first_reply_sent_time