Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 17 Jul 2006 @ 22:41:23 GMT


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


Subj:   Re: How to get top N records
 
From:   Chakrapani, Praveen

Hi Bhakti,

Which version of Teradata are you using ? I think from V2R6.1 a new TOP N feature is added in teradata.

A simple query:

     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.

Restrictions

The TOP option cannot appear in the following:

* Correlated subquery

* Subquery in a search condition

* CREATE JOIN INDEX statement

* CREATE HASH INDEX statement

* Seed statement or recursive statement in a CREATE RECURSIVE VIEW statement or WITH RECURSIVE clause


Hope this helps.


Regards,

Praveen



     
  <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