Multiple select in Tearadata sub query

Database

Multiple select in Tearadata sub query

Hi,

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,

Rakesh.

Tags (1)
1 REPLY
N/A

Re: Multiple select in Tearadata sub query

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'