Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 29 May 2012 @ 13:09:24 GMT


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


Subj:   Re: What is difference between Sample 10 and Top 10?
 
From:   Anomy Anom

<-- Anonymously Posted: Tuesday, May 29, 2012 07:05 -->

Hi,

As you have mentioned, the difference comes into picture when you have an ORDER by clause. TOP 10 will give the top 10 rows after sorting the result set, whereas SAMPLE 10 will chose 10 rows randomly after sorting the result set.

Please check the Explain for the below sqls to get an idea about it.

     Select Top 5 * from dbc.tables
     order by tablename;

     Select * sample 5  from dbc.tables
     order by tablename;

Regarding the performance - From what I have seen, SAMPLE will perform better than TOP.

HTH.



     
  <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