title: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery
body: <pre><code>declare @ProductDetails as table(ProductName nvarchar(200),ProductDescription nvarchar(200),
  Brand nvarchar(200),
  Categry  nvarchar(200),
  Grop nvarchar(200),
  MRP decimal,SalesRate decimal,CurrentQuantity decimal,AvailableQty decimal)
  
  declare @AvailableQty table(prcode nvarchar(100),Aqty decimal)
  
  declare @CloseStock table(pcode nvarchar(100),
  Cqty decimal)
  
  insert into @CloseStock
  select PCODE ,
  0.0
  from producttable
  
  insert into @AvailableQty
  select PCODE ,
  0.0
  from producttable
  
  --Current Qty
  --OpenQty
  update @CloseStock set Cqty=((OOQTY+QTY+SRRQTY+PYQTY)-(STQTY+PRRQTY))
  from
  (
  select PC.PCODE as PRODUCTCODE,
  --Opening
  (select case when SUM(PU.Quantity)is null then 0 else SUM(PU.Quantity) end as Q from ProductOpeningYearEnd PU
  where PC.PCODE=PU.ProductName) as OOQTY,
  --Purchase
  (select case when SUM(PU.quantity)is null then 0 else SUM(PU.quantity) end as Q from purchase PU
  where PC.PCODE=PU.prdcode ) as QTY,
  --Sales
  (select case when SUM(ST.QUANTITY)is null then 0 else SUM(ST.QUANTITY)end as Q2 from salestable ST
  where PC.PCODE=ST.PRODUCTCODE and ST.status!='cancel' )as STQTY,
  --Physical Stock
  (select case when SUM(PS.Adjustment)is null then 0 else SUM(PS.Adjustment)end as Q3 from physicalstock PS
  where PC.PCODE=PS.PCODE )as PYQTY,
  --Sales Return
  (select case when SUM(SR.quantity)is null then 0 else SUM(SR.quantity)end as Q3 from salesreturn SR
  where PC.PCODE=SR.prdcode )as SRRQTY,
  --Purchase Return
  (select case when SUM(PR.quantity)is null then 0 else SUM(PR.quantity)end as Q3 from purchasereturn PR
  where PC.PCODE=PR.prdcode )as PRRQTY
  
  from producttable PC
  group by PC.PCODE
  )t
  where PCODE=t.PRODUCTCODE
  
  --Available
  update @AvailableQty set Aqty=((CCqty-GIQty)+(GOQty))
  --((OOQTY+QTY+SRRQTY+PYQTY)-(STQTY+PRRQTY))
  from
  (
  select PC.PCODE as PRODUCTCODE,
  --GoodsIn
  (select case when SUM(GI.quantity)is null then 0 else SUM(GI.quantity) end as Q from goodsin GI
  where PC.PCODE=GI.productcode) as GIQty,
  --GoodsOut
  (select case when SUM(GUT.quantity)is null then 0 else SUM(GUT.quantity) end as Q from goodsout GUT
  where PC.PCODE=GUT.productcode ) as GOQty,
  --Current Stock
  (select CS.Cqty as Q from @CloseStock CS 
  where PC.PCODE=CS.pcode ) as CCqty
  from producttable PC
  group by PC.PCODE
  )t
  where prcode=t.PRODUCTCODE
  
  insert into @ProductDetails
  select PCODE,[DESCRIPTION],BRAND,CATEGORY,DEPARTMENT,MRP,SALERATE,0,0
  from producttable
  
  update @ProductDetails set CurrentQuantity=pcqty,AvailableQty=acqty
  from
  (
  select pt.ProductName as pn,cs.Cqty as pcqty,ac.Aqty as acqty from @ProductDetails pt
  inner join @CloseStock cs on pt.ProductName=cs.pcode
  inner join @AvailableQty ac on pt.ProductName=ac.prcode     
  )t
  where ProductName=t.pn
  
  select * from @ProductDetails
  
  end
  </code></pre>
  
  <p>This not working when productable in pcode field add ant (-.&amp;) this kind of symbol i want to even allow in pcode field, 
  please help me how i can allow any symbol in query</p>
  
  <p>(problem with this code)
  update @AvailableQty set Aqty=((CCqty-GIQty)+(GOQty))
      from
      (
      select PC.PCODE as PRODUCTCODE,
      --GoodsIn
      (select case when SUM(GI.quantity)is null then 0 else SUM(GI.quantity) end as Q from goodsin GI
      where PC.PCODE=GI.productcode) as GIQty,
      --GoodsOut
      (select case when SUM(GUT.quantity)is null then 0 else SUM(GUT.quantity) end as Q from goodsout GUT
      where PC.PCODE=GUT.productcode ) as GOQty,
      --Current Stock
      (select CS.Cqty as Q from @CloseStock CS 
      where PC.PCODE=CS.pcode ) as CCqty
      from producttable PC
      group by PC.PCODE
      )t
      where prcode=t.PRODUCTCODE   </p>