Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 07 Mar 2008 @ 09:32:12 GMT


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


Subj:   Re: Teradata Query with Subselect
 
From:   Victor Sokovin

  I have never written SQL with a select nested in the select statement...  


If you want to try how it works I would suggest Oracle.

     SELECT 1, (SELECT 2 FROM dual)
     FROM dual;

DUAL is just for illustration purpose, it is a pseudo-table from which you can select whatever you want. We need to use it in Oracle because Oracle does not like FROM-less queries.

In reality the query would use two different tables. For example, the second SELECT may extract some context specific "constant" from a reference table which does not have columns which would allow for an obvious JOIN conditions with the main table.

Code generators like this feature very much as it allows them to build complex, yet fast, queries out of different building blocks which would typically be stored in different tables, without bothering about the columns they can join on. You would often find this type of queries behind Oracle-based applications where users can freely customize their screens (and, of course, the feeding queries behind them).


Victor



     
  <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