我有这样的查询:
<div id="app">
<div v-html="data.template"></div>
</div>
并且当我仅运行此部分时返回null。
DECLARE @AbandonTime int
SET @AbandonTime += (SELECT SUM(DATEDIFF(second,CheckinTime,ServiceStart)) FROM Interaction
WHERE ServiceEnd = '00:00:00.000')
SELECT @AbandonTime
它返回1378条记录。如何计算时差之和?
答案 0 :(得分:1)
您需要初始化该值,因为NULL
加上任何值仍为NULL
:
DECLARE @AbandonTime int;
SET @AbandonTime = 0;
SET @AbandonTime += (SELECT SUM(DATEDIFF(second, CheckinTime, ServiceStart))
FROM Interaction
WHERE ServiceEnd = '00:00:00.000'
);
SELECT @AbandonTime;
当然,您可以将其简化为:
DECLARE @AbandonTime int;
SELECT @AbandonTim = SUM(DATEDIFF(second, CheckinTime, ServiceStart))
FROM Interaction
WHERE ServiceEnd = '00:00:00.000';
SELECT @AbandonTime;