我正在使用Management Studio,并希望基于现有列创建自定义列。我有一个现有的列,它具有票证的优先级。优先级列的数据类型为int。因此,基本上,不同的优先级具有不同的SLA时间。
这是小时数:
是否可以在我正在使用的以下查询中执行此操作?:
SELECT
[plugin.tickets].[Ticket].Id
,[plugin.tickets].[Ticket].Title
,[plugin.tickets].[Ticket].Created
,[plugin.tickets].[Ticket].StartProgress
,[plugin.tickets].[Ticket].firstresponse
,q.OpenstaandeTijdInUren
,s.ReactietijdInUren
,CONVERT(VARCHAR(5),(DATEADD(MINUTE, SUM(DATEDIFF(MINUTE, '00:00:00', EndTime)), '00:00:00')),108) as FacturatieTijd
,[plugin.tickets].[Ticket].Status
,[plugin.tickets].[Ticket].Priority
FROM [plugin.tickets].[Ticket]
LEFT JOIN [plugin.tickets].TicketActivity ON TicketActivity.TicketId = [plugin.tickets].Ticket.Id
LEFT JOIN [dbo].Activity ON Activity.Id = TicketActivity.ActivityId
Cross Apply (select [dbo].[worktime]([plugin.tickets].[Ticket].Created, GetDate()) as OpenstaandeTijdInUren) q
Cross Apply (select [dbo].[worktime]([plugin.tickets].[Ticket].Created, [plugin.tickets].[Ticket].FirstResponse) as ReactietijdInUren) s
where
[plugin.tickets].[Ticket].Created >= DATEADD(DAY, -30000, GETDATE())
AND [plugin.tickets].[Ticket].Created < DATEADD(HOUR, -1, GETDATE())
AND [plugin.tickets].[Ticket].status <= 2
AND q.OpenstaandeTijdInUren >= 1
GROUP BY
[plugin.tickets].[Ticket].id
,[plugin.tickets].[Ticket].Title
,[plugin.tickets].[Ticket].Created
,[plugin.tickets].[Ticket].StartProgress
,[plugin.tickets].[Ticket].firstresponse
,[plugin.tickets].[Ticket].Status
,[plugin.tickets].[Ticket].Priority
,q.OpenstaandeTijdInUren
,s.ReactietijdInUren
ORDER BY
[plugin.tickets].[Ticket].id
我的最终目标是检查哪张票已接近其SLA时间。
谢谢
破旧