Click here to Skip to main content
15,936,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This SQL Query arises the following error :
"
XML
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

" Please explain me subquery and its use :
SQL
select (select L.lineName from tblLine L inner join TERMSHR..tblCompany C on L.CompanyCode=C.CompanyCode where L.Location='Mirpur'
) as LineName from tblDayMonthProductionEntry where ProductionDate between '1-Aug-2013' and '5-Aug-2013' and Location='Mirpur'
Posted

This query is the subquery. It returns more than one row. When you put it inside parenthesis and named it as a column with the As keyword, you designated it as a subquery.
SQL
(select L.lineName from tblLine L inner join TERMSHR..tblCompany C on L.CompanyCode=C.CompanyCode where L.Location='Mirpur') As LineName


Without seeing the DDL for the tables and understanding the output requirements, it is difficult to advise you on a solution.
 
Share this answer
 
The problem is that your query has multiple results, and each result must be in his own result row.
Yor query is trying to get all results in a unique row.

This sample can help you.

Select lineName
From (select L.lineName from tblLine L
inner join TERMSHR..tblCompany C on L.CompanyCode=C.CompanyCode
Where L.Location='Mirpur'
) as LineName
Where ProductionDate between '1-Aug-2013' and '5-Aug-2013' and Location='Mirpur'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900