All Forums Database
pairakesh 1 post Joined 07/14
03 Jul 2014
Multiple select in Tearadata sub query

I am stuck with a query from hours. I have a situation where I need to get multiple values from a subquery with a join in the main table. 
Below is my query. 
Select Employee Id, Department, Division ,
(If Department = 'ABC' Then
Select Address1, Address2, City etc from AddressDb B Where  A.EmployeeId = B.EmployeeId 
End If)
From EmployeeDb A;
This query is not working. Can you please help me get a solution to this or some way where I can achive this ?
Thank you,

dnoeth 4628 posts Joined 11/04
03 Jul 2014

Hi Rakesh,
there's no IF in Teradata SQL and a subquery can never return more than 1 value.
This will get the same result:

Select Employee Id, Department, Division ,
Address1, Address2, City etc  
From EmployeeDb A left join AddressDb B
on A.EmployeeId = B.EmployeeId
and Department = 'ABC'  


You must sign in to leave a comment.