I was writing sub query in stored procedure to get the values between Orders stored as varchar datatype. When i run the query it shows:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I googled a bit and found the problem because of returning more than 1 value in a sub query.
But in my case i need all the values which lies between the given input. Can anybody tell me what way i can achieve this ..
Code:
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'