Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 03 Nov 2010 @ 10:19:30 GMT


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


Subj:   Re: Need Same Order as in input table
 
From:   yash.ballani

Hi Lakhwant,

Below query will give you the desired result:-

     Insert into Table-B
     (
             Row_nbr,
             ,Field1
             ,Field2
             ,Field3
             ,Field4
     )
     Select
             Row_number() Over (Order By Field1, Field2, Field3,Field4)
             ,Field1
             ,Field2
             ,Field3
             ,Field4
     From    Table-A;

Reason:- If you do Sel * from Table A; - You will get random result set reason being rows are not stored in any specific order in Teradata or what sequence you Insert Records doesn t matter.

Further the problem with your query was you didn t include Field4 in Order By Clause. Therefore Teradata Sorted the result set based on 3 Fields only.


Regards,

Yash Ballani



     
  <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