on 02-23-2017 7:14 AM
Dear all,
I face an issue in Query generator.
When i execute the query in query generator, the error is like this
1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
select ShortName 'customer code',
(select OCRD.cardname from ocrd where cardcode =shortname) 'Customer Name',
(select OCRD.U_region from ocrd where cardcode =shortname) 'Branch',
(Select oslp.slpname from oslp left outer join
ocrd on ocrd.slpcode=oslp.slpcode Where ocrd.cardcode=shortname)[Sales Employee],
(select OCRG.Groupname from OCRG where ocrg.GroupCode in
(Select ocrd.GroupCode from ocrd Where ocrd.cardcode=JDT1.shortname))[Customer Group],
(select OCRD.City from ocrd where cardcode =shortname) [City]
,(select top 1 name from ocst where Code in(select OCRD.State1 from ocrd where cardcode =shortname)) [State]
,
(Select C1.Balance from Ocrd C1 where C1.Password=ShortName)[Deposit New From Dealer],
OCRD.CreditLine[Credit Limit],(OCRD.Balance) "Total Outstanding",
(OCRD.CreditLine-(OCRD.Balance))[Limit Avaibility],
ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum in(6,12,13,19,10,15)
and paidsum<doctotal and docdate < dateadd(dd,-7,convert(date,getdate()))
AND DocStatus<>'C'
),0.00) " Overdue COD",
ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum not in(6,12,13,19,10,15)
and paidsum<doctotal and docdate < dateadd(dd,-35,convert(date,getdate()))
AND DocStatus<>'C'
),0.00) "Overdue NON COD"
from JDT1 left outer join OCRD on OCRD.CardCode=JDT1.ShortName
where JDT1.refDate <= GETDATE()
And OCRD.CardType='C'
group by JDT1.ShortName,OCRD.Balance,OCRD.CreditLine ,OCRD.OrdersBal
Does any one know where is the problem ?
Thanks in advance
Hello,
Make sure to use Top 1 in each sub query. Thats it.
Thanks,
Engr. Taseeb Saeed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this,
select ShortName 'customer code',
(select OCRD.cardname from ocrd where cardcode =shortname and Cardtype = 'c' ) 'Customer Name',
(select OCRD.U_region from ocrd where cardcode =shortname and Cardtype = 'c') 'Branch',
(Select oslp.slpname from oslp left outer join
ocrd on ocrd.slpcode=oslp.slpcode Where ocrd.cardcode=shortname)[Sales Employee],
(select OCRG.Groupname from OCRG where ocrg.GroupCode in
(Select ocrd.GroupCode from ocrd Where ocrd.cardcode=JDT1.shortname))[Customer Group],
,(select top 1 name from ocst where Code in(select OCRD.State1 from ocrd where cardcode =shortname)) [State]
,
(Select C1.Balance from Ocrd C1 where C1.Password=ShortName)[Deposit New From Dealer],
OCRD.CreditLine[Credit Limit],(OCRD.Balance) "Total Outstanding",
(OCRD.CreditLine-(OCRD.Balance))[Limit Avaibility],
ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum in(6,12,13,19,10,15)
and paidsum<doctotal and docdate < dateadd(dd,-7,convert(date,getdate()))
AND DocStatus<>'C'
),0.00) " Overdue COD",
ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum not in(6,12,13,19,10,15)
and paidsum<doctotal and docdate < dateadd(dd,-35,convert(date,getdate()))
AND DocStatus<>'C'
),0.00) "Overdue NON COD"
from JDT1 left outer join OCRD on OCRD.CardCode=JDT1.ShortName
where JDT1.refDate <= GETDATE()
And OCRD.CardType='C'
group by JDT1.ShortName,OCRD.Balance,OCRD.CreditLine ,OCRD.OrdersBal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nagarajan,
When i run these query in Sql server then error show on below line Item,
select ShortName 'customer code'
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.
Regards
Amol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you able to run your query in SQL server? Then may be you can find which line returning more than one value.
OR
Logout from SAP b1 and then try to run same query again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Nagarajan,
Could you please provide any solutions.
Regards
Amol B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tested in my DB, getting result after running your query. From the error message, one of sub query returns more than one value. You need find which sub query returns more than one value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this query,
select ShortName 'customer code', (select OCRD.cardname from ocrd where cardcode =shortname) 'Customer Name', (Select oslp.slpname from oslp left outer join ocrd on ocrd.slpcode=oslp.slpcode Where ocrd.cardcode=shortname)[Sales Employee], (select OCRG.Groupname from OCRG where ocrg.GroupCode in (Select ocrd.GroupCode from ocrd Where ocrd.cardcode=JDT1.shortname))[Customer Group], (select OCRD.City from ocrd where cardcode =shortname) [City] ,(select top 1 name from ocst where Code in(select OCRD.State1 from ocrd where cardcode =shortname)) [State] , (Select C1.Balance from Ocrd C1 where C1.Password=ShortName)[Deposit New From Dealer], OCRD.CreditLine[Credit Limit],(OCRD.Balance) "Total Outstanding", (OCRD.CreditLine-(OCRD.Balance))[Limit Avaibility], ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum in(6,12,13,19,10,15) and paidsum<doctotal and docdate < dateadd(dd,-7,convert(date,getdate())) AND DocStatus<>'C' ),0.00) " Overdue COD", ISNULL((select sum(doctotal-paidsum) from OINV where cardcode=JDT1.shortname and groupnum not in(6,12,13,19,10,15) and paidsum<doctotal and docdate < dateadd(dd,-35,convert(date,getdate())) AND DocStatus<>'C' ),0.00) "Overdue NON COD" from JDT1 left outer join OCRD on OCRD.CardCode=JDT1.ShortName where JDT1.refDate <= GETDATE() And OCRD.CardType='C' group by JDT1.ShortName,OCRD.Balance,OCRD.CreditLine ,OCRD.OrdersBal
Regards,
Nagarajan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.