Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 10 May 2006 @ 13:41:19 GMT


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


Subj:   Re: The first lines for the result of a request
 
From:   Lunn, Jonathan

Jean-Michel,

Assuming you are running V2R6.0 or higher, your best choice is to use the TOP option. From the manual:

Use the TOP option to obtain a portion of the data in the query result set. For example, the following query obtains 10 rows from the orders table:

     SELECT TOP 10 * FROM orders;

To obtain a portion of the data from an ordered set, use the TOP option with the ORDER BY clause. For example, the following query obtains the last five orders shipped:

     SELECT TOP 5 * FROM orders ORDER BY ship_date DESC;

If the TOP option specifies a number greater than the number of rows in the query result set, then the query returns the rows in the query result set without producing an error.

So, to use your earlier example;

     Select c1 , c2
     >From  t1
     Where rownum < = 50
     Order by c1

using the TOP N option, it would be;

     Select TOP 50 c1 , c2
     >From  t1
     Order by c1

Regards,

Jonathan



     
  <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: 15 Jun 2023