Hi,
When i am running this code ,it is giving me this error,
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
the code is like below,please resolve my problem ASAP.
Select ttt.FdDmCd,ttt.Col,ttt.CFP,sum(ttt.Qty)as FgQty,sum(ttt.gwt) as GldWt,sum(ttt.swt)as SilWt From
(Select Fdbyy,fdbchr,fdbno,(select OdDmCol from OrdDsg Where Odtc=FdPrdOdtc and Odyy=FdPrdOdyy and odchr=FdPrdOdChr and
Odno=FdPrdOdNo and odsr=FdPrdOdSr)as col, (Select OlScd FRom OrdLab where OlMcd='CFP' and Oltc=FdPrdOdtc and
Olyy=FdPrdOdyy and olchr=FdPrdOdChr and Olno=FdPrdOdNo and olSr=FdPrdOdSr)as CFP, Max(FdDmCd)as FdDmCd,max(FdQty) as Qty,
(Select Sum(case when frrmctg ='G' and frrmsctg='-' then FrRmWt else 0 end) from fgrm Where FrFdIdNo =Max(FDIdNo)
Group by FrFdIdNo)as GWt, (Select Sum(case when frrmctg ='S' and frrmsctg='-' then FrRmWt else 0 end) from fgrm
Where FrFdIdNo =Max(FDIdNo) Group by FrFdIdNo)as SWt from fgd Join (Select Distinct fdbyy as fdbyy1,fdbchr as fdbchr1 ,
fdbno as fdbno1,Count(*)as Count1 from fgd Where fddt between '01/04/14' and '02/04/14' and fdtc='FB' and fdsubloc = 'exp'
and FdPrdOdChr in ('JKS','KPS','JOB')
Group by fdbyy,fdbchr,fdbno ) as tab on fdbyy=tab.fdbyy1 and fdbchr=tab.fdbchr1 and fdbno=tab.fdbno1
Where fddt between '01/04/14' and '02/04/14' and fdtc='FB' and FdPrdOdChr in ('JKS','KPS','JOB')
group by Fdbyy,fdbchr,fdbno ,FdPrdOdtc ,FdPrdOdyy,FdPrdOdChr,FdPrdOdNo,FdPrdOdSr
Union all
Select Fdbyy,fdbchr,fdbno,(select OdDmCol from OrdDsg Where Odtc=FdPrdOdtc and Odyy=FdPrdOdyy and odchr=FdPrdOdChr and
Odno=FdPrdOdNo and odsr=FdPrdOdSr)as col, (Select OlScd FRom OrdLab where OlMcd='CFP' and Oltc=FdPrdOdtc and
Olyy=FdPrdOdyy and olchr=FdPrdOdChr and Olno=FdPrdOdNo and olSr=FdPrdOdSr)as CFP, FdDmCd,FdQty,
(Select Sum(case when frrmctg ='G' and frrmsctg='-' then FrRmWt else 0 end) from fgrm Where FrFdIdNo =FDIdNo
Group by FrFdIdNo)as GWt, (Select Sum(case when frrmctg ='S' and frrmsctg='-' then FrRmWt else 0 end) from fgrm
Where FrFdIdNo =FDIdNo Group by FrFdIdNo)as SWt from fgd Join (Select Distinct fdbyy as fdbyy1,fdbchr as fdbchr1 ,
fdbno as fdbno1 from fgd Where fddt between '01/04/14' and '02/04/14'
and fdtc='FB' and FdPrdOdChr in ('JKS','KPS','JOB') group by Fdbyy,fdbchr,fdbno ,FdPrdOdtc ,FdPrdOdyy,FdPrdOdChr,
FdPrdOdNo,FdPrdOdSr ) as tab on fdbyy=tab.fdbyy1 and fdbchr=tab.fdbchr1 and fdbno=tab.fdbno1
Where fddt between '01/04/14' and '02/04/14' and fdtc='FB' and fdsubloc = 'exp' and
FdPrdOdChr in ('JKS','KPS','JOB') ) as ttt Group by ttt.FdDmCd,ttt.Col,ttt.CFP