0

首先,对不起我的英语不好,我是法裔加拿大人。

我正在尝试比较多个开始日期时间和结束日期时间之间的一个日期时间,但我的查询不起作用,SQL Server 给了我这个错误:“子查询返回超过 1 个值。当子查询跟随 =,时,这是不允许的! =、<、<=、>、>= 或当子查询用作表达式时。"

SELECT V.SampleTime,
       V.OrderNo,
       V.VNCCode,
       V.VNCDescription,
       V.NrOfOccurences,
       V.Comment
FROM AV_RPT_FQC_Visual V
INNER JOIN AV_RPT_PO_Header H
ON H.OrderNo=V.OrderNo
WHERE H.LinkUp IN (SELECT * FROM @iLinkupID) 
AND (V.NrOfOccurences > 0 or V.VNCCode = '00.00.00')
-- This part doesn't work --> AND SampleTime between (Select ShiftStart From @shifts) and (Select ShiftEnd From @shifts)
ORDER BY SampleTime, VNCCode

十分感谢。:)

4

2 回答 2

0

根据您的评论,您可能想试试这个。PS,我也是加拿大人:)

AND EXISTS (Select 1 From @shifts ss WHERE V.SampleTime BETWEEN ss.ShiftStart AND ss.ShiftEnd)
于 2013-11-12T13:46:12.220 回答
0

尝试 AND SampleTime between (Select min(ShiftStart) From @shifts) and (Select max(ShiftEnd) From @shifts)

于 2013-11-05T19:58:38.170 回答