Embedded Selects statements within a select stmt

Analytics
FM
N/A

Embedded Selects statements within a select stmt

Hi,

I am new to Teradata but have worked previously with Oracle.

I want to embed a select statement within another select statement like

select t.col1,t.col2,(select x.colname from another_table x)
from test t

I am getting the following error:
3706: Syntax error: expected something between '(' and the 'sel' keyword.
Any ideas on how to get around this?

Thanks
3 REPLIES
Enthusiast

Re: Embedded Selects statements within a select stmt

You will not be able to do this in a column selection, just use a join strategy to get the required result.
gam
Fan

Re: Embedded Selects statements within a select stmt

Hi,

I'm curious if something has changed in this case, or till it doesnt work in TD.

Thanks

Supporter

Re: Embedded Selects statements within a select stmt

Depends on your release. 

In 13.10 below works - query need to guarantee that only one row is returned!


select calendar_date, 


       (select count(*) from sys_calendar.calendar where year_of_calendar = extract(year from current_Date)) as num_of_days_in_year


from sys_calendar.calendar


where year_of_calendar = extract(year from current_date)


;