Former Member
Sep 19, 2011 at 04:16 AM

# Solve this problem......"Subquery returned more than 1 value"

337 Views

Hi Experts,

Tell me the solution for this problem......

" Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."

This is the query...

SELECT DISTINCT ORPC.DocEntry, ORPC.DocNum AS 'Debit Note No.', ORPC.CardName AS 'Name', ORPC.CardCode AS 'code', ORPC.NumAtCard AS 'Supplier Ref.',

OCTG.PymntGroup AS 'Payment Terms', OSHP.TrnspName AS 'Shipping type', RPC1.Dscription AS 'Description of Goods', ORPC.Address,

RPC1.Quantity, RPC1.Price AS 'Rate', RPC1.LineTotal AS 'Amount', ORPC.DocDate,

(SELECT DISTINCT TaxRate FROM RPC4

WHERE (staType = - 90) AND (StaCode = 'BED@10') AND (DocEntry = RPC1.DocEntry)) AS 'Basic Excise Duty BED@10 %',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_8

WHERE (staType = - 60) AND (DocEntry = RPC1.DocEntry)) AS 'Education Cess @2%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_7

WHERE (staType = - 55) AND (DocEntry = RPC1.DocEntry)) AS 'Secondary Education Cess @1%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_6

WHERE (staType = 4) AND (StaCode = 'CST2') AND (DocEntry = RPC1.DocEntry)) AS 'Central Sales Tax(CST)@2%',

(SELECT DISTINCT TaxRate FROM PCH4

WHERE (staType = 4) AND (StaCode = 'CST12.5') AND (DocEntry = RPC1.DocEntry)) AS 'Central Sales Tax(CST)@12.5%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_5

WHERE (staType = 1) AND (StaCode = 'VAT4') AND (DocEntry = RPC1.DocEntry)) AS 'Input VAT@5%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_4

WHERE (staType = 1) AND (TaxRate = 12.500000) AND (StaCode = 'VAT12.5') AND (StaCode = 'VAT12.5') AND (DocEntry = RPC1.DocEntry)) AS 'Input VAT@12.5%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_3

WHERE (staType = 18) AND (StaCode = 'Add2') AND (DocEntry = RPC1.DocEntry)) AS 'Addtional Tax@1%',

(SELECT DISTINCT TaxRate FROM RPC4 AS RPC4_3

WHERE (staType = 18) AND (StaCode = 'Add1S') AND (DocEntry = RPC1.DocEntry)) AS 'Addtional Tax@1%',

(SELECT DISTINCT TaxSum FROM RPC4

WHERE (staType = - 90) AND (StaCode = 'BED@10') AND (DocEntry = RPC1.DocEntry)) AS 'BedAmount@10%',

(SELECT DISTINCT TaxSum FROM RPC4

WHERE (staType = - 60) AND (DocEntry = RPC1.DocEntry)) AS 'EcessAmount@2%',

(SELECT DISTINCT TaxSum FROM RPC4

WHERE (staType = - 55) AND (DocEntry = RPC1.DocEntry)) AS 'SecCessAmount@1%',

(SELECT DISTINCT TaxSum FROM RPC4

WHERE (staType = 4) AND (StaCode = 'CST2') AND (DocEntry = RPC1.DocEntry)) AS 'CSTAmount@2%',

(SELECT DISTINCT TaxSum FROM RPC4 AS RPC4_5

WHERE (staType = 1) AND (StaCode = 'VAT4') AND (DocEntry = RPC1.DocEntry)) AS 'VATAmount@5%',

(SELECT DISTINCT TaxSum FROM RPC4 AS RPC4_4

WHERE (staType = 1) AND (TaxRate = 12.500000) AND (StaCode = 'VAT12.5') AND (DocEntry = RPC1.DocEntry)) AS 'VATAmount@12.5%',

(SELECT DISTINCT TaxSum FROM RPC4 AS RPC4_3

WHERE (staType = 18) AND (StaCode = 'Add2') AND (DocEntry = RPC1.DocEntry)) AS 'AddTaxAmount@1%(for VAT@4)',

(SELECT DISTINCT TaxSum FROM RPC4 AS RPC4_3

WHERE (StcCode = 'VAT12.5') AND (staType = 18) AND (StaCode = 'Add1S') AND (DocEntry = RPC1.DocEntry)) AS 'AddTaxAmount@1%(forVAT@12.5)',

(SELECT DISTINCT TaxSum FROM PCH4

WHERE (StcCode = 'B10C125P') AND (TaxRate = 12.500000) AND (staType = 4) AND (StaCode = 'CST12.5') AND (DocEntry = RPC1.DocEntry)) AS 'CSTAmount@12.5%'

FROM ORPC INNER JOIN

RPC1 ON ORPC.DocEntry = RPC1.DocEntry INNER JOIN

OSHP ON ORPC.TrnspCode = OSHP.TrnspCode INNER JOIN

OCTG ON ORPC.GroupNum = OCTG.GroupNum

WHERE (ORPC.CardCode = 'V00522') AND (ORPC.DocNum = '9220005')

Regards

Rahul