I have a query that looks like this:
SELECT
agent_name,
channel,
message_count,
sla_time,
CASE WHEN channel = 'Chat' AND sla_time <= 30 THEN 'SLA Honored' WHEN channel = 'Chat' AND sla_time > 30 THEN 'SLA Breached' WHEN channel = 'Email' AND sla_time <= 15 THEN 'SLA Honored' WHEN channel = 'Email' AND sla_time > 15 THEN 'SLA Breached' WHEN channel = 'Chat and Email' AND sla_time <= 30 THEN 'SLA Honored' WHEN channel = 'Chat and Email' AND sla_time > 30 THEN 'SLA Breached' END SLA_status
FROM (
SELECT
agent_name,
channel,
message_count,
firstResponse_createdAt,
CASE WHEN channel = 'Chat' THEN bt_seconds WHEN channel = 'Email' THEN bt_minutes ELSE bt_seconds END sla_time
FROM (
SELECT
conversation_id,
customer_id,
agent_name,
message_count,
inbound_message_count,
outbound_message_count,
firstResponse_createdAt,
CASE WHEN channel = '["email"]' THEN 'Email' WHEN channel = '["chat"]' THEN 'Chat' WHEN channel LIKE ('%,%') THEN 'Chat and Email' END channel,
ROUND(bt_hour*60,2) bt_minutes,
ROUND((bt_hour*60)*60,2) bt_seconds
FROM (
SELECT
conv.id conversation_id,
relationships.customer.data.id customer_id,
agent_name,
attributes.custom.issueTypeTree issueTypeTree,
attributes.messageCount message_count,
attributes.messageCount - attributes.outboundMessageCount inbound_message_count,
attributes.outboundMessageCount outbound_message_count,
DATE(attributes.firstResponse.createdAt) firstResponse_createdAt,
attributes.firstResponse.time firstResponse_time,
ROUND(((attributes.firstResponse.time/3600000)/24) * 1,3) bt_days,
ROUND(((attributes.firstResponse.time/3600000)) * 10,7) bt_hour,
TO_JSON_STRING(conv.attributes.channels) channel
FROM
kustomer.conversations conv
INNER JOIN (SELECT
id,
attributes.name agent_name
FROM
kustomer.users
LEFT JOIN UNNEST(attributes.roles) roles
LEFT JOIN UNNEST(attributes.roleGroups)
GROUP BY 1,2) users
ON users.id = conv.attributes.firstResponse.createdBy
WHERE attributes.sla.summary.satisfiedAt IS NOT NULL
AND attributes.custom.issueTypeTree NOT IN ('pre_order_question_non_issue.marketing_partnership_request',
'pre_order_question_non_issue.spam',
'pre_order_question_non_issue.unsubscribe')
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12))
)
WHERE {{firstResponse_createdAt}}
But it returns Unrecognized name: kustomer.conversations at [59:28]
If it helps, here are two screenshots that show what it looks like in the UI and how I set it up in the data model.
I've been working on this for hours... please help!