Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 16 Nov 2004 @ 20:34:36 GMT


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


Subj:   Need help with SELECT
 
From:   Anomy Anom

<-- Anonymously Posted: Tuesday, November 16, 2004 15:28 -->

Hi all,

I am having the table like this.

     table: source_test
     columns: id1, id2, timeframe, amount

Table has following records.

     id1 id2 timeframe amount
     1 1 1  10
     1 2 1  0
     1 3 1  0
     1 1 2  10
     1 2 2  60
     1 3 2  0

Now I want to insert the records into target table based on the timeframe target table structure would be like this.

     table: target_test
     columns: id1, id2, timeframe1, camount1, timeframe2, camount2

I want the output to be like this for time=1

     id1  1
     id2  1
     timeframe1 1
     camount1 10
     timeframe2 2
     camount2 20

I want the output to be like this for time=2

     id1  1
     id2  2
     timeframe1 1
     camount1 0
     timeframe2 2
     camount2 60

I want the output to be like this for time=3

     id1  1
     id2  3
     timeframe1 0
     camount1 0
     timeframe2 3
     camount2 0

What is the optimize way to write the select statment.


Thanks



     
  <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: 27 Dec 2016