7
votes

I tried this

SELECT * 
FROM
( SELECT *
FROM mytable;
);

and this

SELECT * 
FROM
( SELECT *
FROM mytable
);

Why these simple queries do not execute in Teradata?

1
To be precise: those aren't "sub-queries", it's called a "derived table". And the first one is invalid because you have a ; inside the derived table. What exactly is the error message you get (when running the second one)? If I had to guess: you need to supply an alias for the derived table: select * from (select * from mytable ) as t - a_horse_with_no_name

1 Answers

12
votes

@a_horse_with_no_name has pointed out clearly. It should be written like this.

SELECT * 
FROM
(
 SELECT *
FROM mytable
) as MY_TABLE;