Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013
    Posts
    1

    Unanswered: ERROR:-Subquery returned more than one value,that is not permitted when sub query fol

    Am getting error:-Subquery returned more than one value,that is not permitted when sub query follows =,<,>.................................Below is my query

    declare @WorkOrder as nvarchar(10)

    Set @WorkOrder =( Select X.PrjCode from OPRJ X Where X.PrjCode='[%1]')


    SELECT L.Project ,l.U_PINo as [Indent No], M.DocNum AS 'GRN No', M.DocDate as 'Date',
    M.CardName as 'Vendor Name',L.ItemCode,l.Dscription,l.Quantity,l.unitMsr as'UOM',l.Price,l.DiscPrcnt ,L.LineTotal,
    isnull((SELECT (TaxSum) FROM PDN4 where statype=-90 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0) +
    isnull((SELECT (TaxSum) FROM PDN4 where statype=-60 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)+
    isnull((SELECT (TaxSum) FROM PDN4 where statype=-55 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0) as 'Excise Duty ',
    isnull((SELECT (TaxSum) FROM PDN4 where statype=1 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0) as ' VAT ',
    isnull((SELECT (TaxSum) FROM PDN4 where statype=4 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0) as ' CST ',
    isnull((Select (LineTotal) From PDN3 Q Where Q.DocEntry=M.DocEntry and L.LineNum =q.BaseLnNum),0) AS 'Others',
    l.LineTotal
    +isnull((SELECT (TaxSum) FROM PDN4 where statype=-90 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)
    +isnull((SELECT (TaxSum) FROM PDN4 where statype=-60 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)
    +isnull((SELECT (TaxSum) FROM PDN4 where statype=-55 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)
    +isnull((SELECT (TaxSum) FROM PDN4 where statype=1 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)
    +isnull((SELECT (TaxSum) FROM PDN4 where statype=4 and DocEntry=M.DocEntry and L.LineNum =PDN4.LineNum),0)
    +isnull((Select (LineTotal) From PDN3 Q Where Q.DocEntry=L.DocEntry and L.LineNum =q.BaseLnNum),0)
    +isnull((Select (LineTotal) From PDN3 Q Where Q.DocEntry=L.DocEntry and L.LineNum =q.BaseLnNum),0) as 'Total'
    FROM opdn M LEFT OUTER JOIN pdn1 L on L.DocEntry=M.DocEntry
    LEFT OUTER JOIN PDN4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
    LEFT OUTER JOIN PDN5 J ON M.DocEntry = J.AbsEntry
    LEFT OUTER JOIN PDN3 Q ON M.DocEntry = Q.DocEntry
    LEFT OUTER JOIN PDN3 Q1 ON L.LineNum = Q1.BaseLnNum
    where
    L.Project=@WorkOrder and M.CANCELED<>'Y' and
    L.Project is not null
    GROUP BY
    L.Project ,M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEn try,M.DiscSum,M.WTSum,M.DocTotal,
    l.U_PINo,L.ItemCode,l.Dscription,l.Quantity,l.unit Msr,l.Price,l.DiscPrcnt , l.LineTotal,l.LineNum ,q.BaseLnNum,L.DocEntry
    ORDER BY
    M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEnt ry,M.DiscSum,M.WTSum,M.DocTotal

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Just comment out all the select statements and try one at a time until you find out which one is returning more than one value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •