Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 nested query

Author  Topic 

vipin_jha123
Starting Member

31 Posts

Posted - 2011-04-11 : 01:51:58
i want ti take the below given query in ouet select

Select gam.foracid
From TBAADM.GAM
Where gam.acid In (Select gam.acid From tbaadm.gam, tbaadm.tam
Where GAM.acid = TAM.repayment_acid)

but when i am doing that i am getting error of

ORA-01427: single-row subquery returns more than one row

i want the above query like

select gam.acct_name,gam.cif_id,gam.schm_code,(Select gam.foracid
From TBAADM.GAM
Where gam.acid In (Select gam.acid From tbaadm.gam, tbaadm.tam
Where GAM.acid = TAM.repayment_acid)) table1

from tbaadm.gam

please provide the necessery result



lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-04-11 : 03:11:43
select acct_name,
cif_id,
schm_code,
( Select foracid
From TBAADM InnerTable
Where acid = OuterTable.repayment_acid
) AS foracid
from tbaadm OuterTable

-- OR

SELECT FirstTable.acct_name,
FirstTable.cif_id,
FirstTable.schm_code,
SecondTable.foracid
FROM tbaadm FirstTable
INNER JOIN tbaadm SecondTable ON FirstTable.repayment_acid = SecondTable.acid

--------------------------
http://connectsql.blogspot.com/
Go to Top of Page
   

- Advertisement -