Click here to Skip to main content
15,896,439 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select a.billamt,b.itemcode,(select IsActivated from tblSuperSellDetail where SellId=7)as isactivated
from tblSellMaster a inner join tblSellDetail b on a.SellId =b.SellId
where a.SellId =7


I am getting following error, Please suggest me how to solve this. There are multiple record in tblSellDetail and tblSuperSellDetail regarding one sellId in tblSellMaster

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.
Posted

the subquery(select IsActivated from tblSuperSellDetail where SellId=7) reutrning more than one value. so use top 1 clause with select to fetch only one record or Distinct clause

ex:

SQL
select Top 1IsActivated from tblSuperSellDetail where SellId=7
or
SQL
select Distinct(IsActivated) from tblSuperSellDetail where SellId=7
 
Share this answer
 
v4
Try this:
SQL
select a.billamt,b.itemcode,(select TOP(1) IsActivated from tblSuperSellDetail where SellId=7) as isactivated
from tblSellMaster a inner join tblSellDetail b on a.SellId =b.SellId
where a.SellId =7


NOTE: This is not prefered solution. Rather then using subquery, use JOIN to join next table ;)
 
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