我有以下每周在 Spiceworks 服务器上运行的报告,供我们的 IS 和 IT 部门用作衡量我们分配帮助台票证所需时间的指标。它选择以下内容:
- 票证编号
- 工单创建日期
- 计算分配所花费的时间(分配时间 - 创建时间)
- 票分配给谁
- 谁分配了票
where 子句查找带有“分配给”信息的评论,并且仅获取过去 7 天中分配给 IT 部门用户的票证。
我正在尝试向此查询添加最后一行,该行将平均部门分配工单所花费的时间。我读到了 rollup() 函数,但它不是公认的 Sqlite 方法。
任何提示或建议都会很棒!谢谢!
--Based on report by Ben Brookshire, Spiceworks Inc.
SELECT t.id as ID,
t.created_at as TicketCreated,
--CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END
CASE
WHEN (((strftime('%s',c.created_at) - strftime('%s',t.created_at))/60) < 1) THEN (strftime('%s',c.created_at) - strftime('%s',t.created_at)) || " seconds"
WHEN (((strftime('%s',c.created_at) - strftime('%s',t.created_at))/3600) < 1) THEN round((strftime('%s',c.created_at) - strftime('%s',t.created_at))/60,3) || " minutes"
WHEN (((strftime('%s',c.created_at) - strftime('%s',t.created_at))/3600) > 1) THEN round((strftime('%s',c.created_at) - strftime('%s',t.created_at))/3600.0,3) || " hours"
WHEN (((strftime('%s',c.created_at) - strftime('%s',t.created_at))/3600) > 24) THEN round((strftime('%s',c.created_at) - strftime('%s',t.created_at))/86400.0,3) || " days"
ELSE "error"
--round((strftime('%s',c.created_at) - strftime('%s',t.created_at))/3600.0,3) as "Time to Assign (hours)",
END as "Time to Assign",
u.email as AssignedTo,
u2.email as AssignedBy
FROM tickets t
LEFT JOIN comments c ON c.ticket_id = t.id
LEFT JOIN users u ON u.id = t.assigned_to
LEFT JOIN users u2 ON u2.id = c.created_by
WHERE c.body LIKE "%Assigned to%"
AND c.created_at BETWEEN date('now', '-6 days') AND date('now')
AND (u.email = "todd@email.com" OR u.email = "andy@email.com")
ORDER BY t.id;