Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 04 May 2004 @ 19:16:05 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Dummy objectname in FROM clause
 
From:   Dieter Noeth

Anomy Anom wrote:

  Isn't there a dummy objectname you can specify in Teradata SQL where you must include the FROM clause even though you don't actually need to access a table?  


There's no DUAL ;-)


  I know in some cases you don't need the FROM clause, e.g., 'SELECT DATE;'. But for example queries with UNION will fail:  


     select 1
     union
     select 0;

     3888:  A SELECT for a UNION,INTERSECT or MINUS must reference a table.

Using Derived Tables:

     select * from (select 1 as x) dt
     union
     select * from (select 0 as x) dt;

Look at that stupid explain.


  I could swear I heard about this 'dummy table' in a Teradata Education class a few years ago but have never had occasion to use it.  


It wasn't me ;-)


  I know there are alternatives to this logic, but I am seeking an answer to this specific question.  


     create table dummy(x int not null primary key check (x = 1));

     ins into dummy(1);

     select 1 from dummy where x = 1
     union all
     select 0 from dummy where x = 1;

Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016