我在存儲過程中編寫子查詢以獲取存儲爲varchar數據類型的Orders之間的值。當我運行查詢時,它顯示:SQL Server中的運算符BETWEEN
子查詢返回的值超過1。當子查詢遵循=,!=,<,< =,>,> =或當子查詢用作表達式時,這是不允許的。
我GOOGLE了一下,發現問題,因爲在子查詢中返回多個值。
但在我的情況下,我需要所有在給定輸入之間的值。誰能告訴我有什麼辦法可以做到這一點..
代碼:
SELECT ROW_NUMBER()OVER(
ORDER BY po.id) AS SNo ,
pd.Copies AS Quantity,
pd.EstUnitPrice AS UniPrice,
pd.Copies*pd.EstUnitPrice AS Total,
(SELECT value
FROM BibContents
WHERE bibid=pd.BibId
AND sfld='a'
AND tagno='245') AS Title,
(SELECT value
FROM BibContents
WHERE bibid=pd.BibId
AND sfld='a'
AND tagno='020') AS 'ISSN/ISBN',
(SELECT value
FROM BibContents
WHERE bibid=pd.BibId
AND sfld='a'
AND tagno='100')AS Author
FROM [VibrantMas].[dbo].[PoDetails] AS pd
INNER JOIN Porders AS po ON po.Id=pd.PoId
WHERE po.No BETWEEN '000021' AND '000024'
告訴你什麼,你如何格式化你的TSQL很好... – 2013-02-20 06:39:31
對不起,格式化查詢錯誤。 – UniqueChar 2013-02-20 06:44:17