Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用DateDiff查找以分钟为单位的持续时间_Sql_Sql Server_Tsql_Datediff - Fatal编程技术网

Sql 使用DateDiff查找以分钟为单位的持续时间

Sql 使用DateDiff查找以分钟为单位的持续时间,sql,sql-server,tsql,datediff,Sql,Sql Server,Tsql,Datediff,我试图使用Datediff找出columnA和columnB之间的持续时间 SELECT datediff (minute, stime, etime) from Exceptions2 where stime = [exceptions2].starttime and etime = [exceptions2].endtime 这会产生错误。有人能帮我解决我做错了什么吗?试试看,不知道为什么会有stime=[exceptions 2]。starttime和etime=[exceptions

我试图使用
Datediff
找出
columnA
columnB
之间的持续时间

SELECT datediff (minute, stime, etime)
from Exceptions2
where stime = [exceptions2].starttime
and etime = [exceptions2].endtime

这会产生错误。有人能帮我解决我做错了什么吗?

试试看,不知道为什么会有stime=[exceptions 2]。starttime和etime=[exceptions 2]。endtime

SELECT datediff(minute, starttime, endtime) from Exceptions2

使用
WHERE
子句筛选结果。不幸的是,它不是用来创建别名的。:)如果Raymund的答案是你所寻求的,考虑给他信用,通过标记他作为公认的答案。没有必要仅仅为了评论而发布另一个答案。:)