我有3次將其放到條形圖上,但無法解決如何將AvgUserSegmentTime更改爲時間格式(00:00:00.00)。現在我得到Fastest = 00:00:00.01 Slowest = 00:00:24:22.22和Avg = 61這意味着條形圖上的平均值要大得多。有關如何將int更改爲一次的想法?從DateDiff將int更改爲時間
SELECT FastestSegmentTime , SlowestSegmentTime,
(SELECT AVG(DateDiff(SECOND, tblTrace.trStart , tblTrace.trFinish))
FROM tblTrace
INNER JOIN
tblUsers
ON usrID = tr_usrID
WHERE tblTrace.trFinish IS NOT NULL
AND tblTrace.trObjectType LIKE 'Segment%'
AND tblTrace.tr_vnuID = @vnuID
AND tblTrace.trStart BETWEEN @StartDate AND @EndDate
AND tblUsers.usrEmail NOT LIKE '%@test%') as AvgSegmentTime
FROM (
SELECT MIN(CAST(tblTrace.trFinish - tblTrace.trStart AS TIME(2))) AS FastestSegmentTime,
MAX(CAST(tblTrace.trFinish - tblTrace.trStart AS TIME(2))) AS SlowestSegmentTime
FROM tblTrace
INNER JOIN
tblUsers
ON usrID = tr_usrID
WHERE tr_vnuID = @vnuID
AND trFinish IS NOT NULL
AND tr_usrID IS NOT NULL
AND trObjectType LIKE 'Segment%'
AND trStart BETWEEN @StartDate AND @EndDate
AND tblUsers.usrEmail NOT LIKE '%@test%'
) coreData
您可以使用'Cast('00.00:00.00'作爲Time)'而不是'0'作爲'DateAdd'的第三個參數 – bummi