7

I tried this

SELECT * 
FROM
( SELECT *
FROM mytable;
);

and this

SELECT * 
FROM
( SELECT *
FROM mytable
);

Why these simple queries do not execute in Teradata?

Rob Paller
  • 7,736
  • 29
  • 26
Andrei Vasilev
  • 597
  • 5
  • 18
  • 37
  • 7
    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` –  Nov 19 '13 at 23:32

1 Answers1

13

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

SELECT * 
FROM
(
 SELECT *
FROM mytable
) as MY_TABLE;
Santhosh
  • 1,771
  • 1
  • 15
  • 25