Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 19 Dec 2006 @ 17:53:54 GMT


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


Subj:   Re: Group by of multiple columns for teradata and
 
From:   Victor Sokovin

  I have tried executing the following query in oracle  


          > select  deptno, mgrno, empno from master
          > where <<>>>
          > group by deptno, mgrno,empno;
  The above query gives results first by all department nos, then manager no and then empno.  


  I converted the above query in teradata as  


          > select  deptno, mgrno, empno from master
          > where <<>>>
          > group by deptno, mgrno,empno;
  Although both queries are against the same table, the order in which the rows appear drastically differs. Can someone help me with this?????  


The order in which the rows are displayed may depend on many factors and those factors may depend on the vendor.

If you need a specific order in a reliable way then just add the ORDER BY clause.

For example,

     select  deptno, mgrno, empno from master
     where <<>>>
     group by deptno, mgrno,empno
     ORDER BY deptno, mgrno,empno;

To be honest, even this is not always enough because the ordering rules may depend on the session collation (follow the thread on Thai characters if you are interested in this level of details) but there is a good chance that the ORDER BY is all you need.


Regards,

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