我有一个查询
select
*,
right(
convert(varchar, cast(JOB_DONE_time-JOB_send_time as datetime), 121),
12
) [TimeTaken]
from dbo.insert_data
order by job_id desc
这个查询的结果就像
JOB_ID JOB_DONE_TIME JOB_SEND_TIME TimeTaken
--------- ----------------------- ----------------------- ------------
001-99900 2011-12-28 13:36:57.860 2011-12-28 13:36:57.593 00:00:00.267
001-99800 2011-12-28 13:36:57.843 2011-12-28 13:36:57.593 00:00:00.250
001-99700 2011-12-28 13:36:57.687 2011-12-28 13:36:57.547 00:00:00.140
001-99600 2011-12-28 13:36:57.593 2011-12-28 13:36:57.547 00:00:00.047
001-99500 2011-12-28 13:36:57.563 2011-12-28 13:36:57.437 00:00:00.127
001-99400 2011-12-28 13:36:57.547 2011-12-28 13:36:57.437 00:00:00.110
001-99300 2011-12-28 13:36:57.483 2011-12-28 13:36:57.377 00:00:00.107
001-99200 2011-12-28 13:36:57.437 2011-12-28 13:36:57.377 00:00:00.060
001-99100 2011-12-28 13:36:57.407 2011-12-28 13:36:57.187 00:00:00.220
001-99000 2011-12-28 13:36:57.360 2011-12-28 13:36:57.187 00:00:00.173
001-9900 2011-12-28 13:32:22.657 2011-12-28 13:32:22.500 00:00:00.127
通过这个查询,我得到了TimeTaken
专栏。现在我想计算加法和平均值。的列timetaken
。我尝试过使用SUM()
功能,但它给了我错误:
消息 8117,级别 16,状态 1,行 1 操作数数据类型 varchar 对于求和运算符无效。
怎么计算???