SELECT
Reference_Number,
c.First_Name + ' ' + c.Last_Name AS 'Customer_Name',
Staff_FirstName + ' ' + Staff_LastName AS 'Staff_Name',
Date_Time, Summary, OtherDetails,
CAST(Hold_Time AS TIME(0)) AS 'HoldTime',
CAST(Duration AS TIME(0)) AS 'Duration',
Call_Status
FROM
Support_Call AS tc
INNER JOIN
customer AS c ON c.CustomerID = c.CustomerID
INNER JOIN
staff AS s ON tc.StaffID = s.StaffID
WHERE
Call_Status LIKE 'Pending%'
ORDER BY
Date_Time DESC;
我正在尝试计算未决呼叫的所有详细信息,但出现错误。 Reference_number
的数据类型为INT
答案 0 :(得分:0)
我猜想[Duration](和/或[Hold_Time])是INT类型,如果值以分钟为单位(otherwise change accordingly),则使用:
CAST(DATEADD(mi, Duration, CAST(0 AS DATETIME)) as time(0)) AS 'Duration'
由于您使用TIME(0)数据类型,因此转换后的字段值不能大于24h
答案 1 :(得分:0)
可能有帮助吗?
Declare @Datum varchar(10)='3:00:00 PM'
--Convert it into Hour as integer
Select (cast ( SUBSTRING(@Datum, 1, CHARINDEX(':', @Datum, 1)-1) as numeric (10,2)) +Cast ( (SUBSTRING(@Datum,(CHARINDEX(':', @Datum, 1)+1),2)) as numeric (10,2))/60)
答案 2 :(得分:0)
我解决了这个问题,谢谢大家
SELECT Reference_Number,
First_Name+' '+Last_Name AS 'Customer_Name',
Staff_FirstName+' '+Staff_LastName AS 'Staff_Name',
Date_Time,Summary, OtherDetails,
Call_Status
FROM Support_Call AS tc INNER JOIN customer AS c
ON c.CustomerID = c.CustomerID
INNER JOIN staff AS s
ON tc.StaffID =s.StaffID
WHERE Call_Status LIKE 'Pending%'
ORDER BY Date_Time DESC;