Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 27 Oct 2010 @ 09:43:20 GMT


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


Subj:   Re: Pivot temp table
 
From:   Anomy Anom

<-- Anonymously Posted: Wednesday, October 27, 2010 05:25 -->

Using the approach of Create table XYZ as (Select from source) with DATA;

You may add a row_number() column if needed as suggested earlier.

     BTEQ -- Enter your SQL request orBTEQ command:
     ct t1(col1 int ,col2 int,attr1 int ,attr2 int,attr3 int,attr4 int);

      *** Table has been created.
      *** Total elapsed time was 1 second.
     BTEQ -- Enter your SQL request orBTEQ command:
     ins t1(1,2,1,1,1,1);

      *** Insert completed. One row added.
      *** Total elapsed time was 1 second.


     BTEQ -- Enter your SQL request orBTEQ command:
     ins t1(3,4,1,1,1,1);

      *** Insert completed. One row added.
      *** Total elapsed time was 1 second.


     BTEQ -- Enter your SQL request orBTEQ command:
     ins t1(5,6,1,1,1,1);

      *** Insert completed. One row added.
      *** Total elapsed time was 1 second.

     ++++++++++++++++++++++++++++++++++++++++

     BTEQ -- Enter your SQL request orBTEQ command:
     ct t2 as (sel col1,attr1,attr2,attr3,attr4 from t1) with data;

     ct t2 as (sel col1,attr1,attr2,attr3,attr4 from t1) with data;

      *** Table has been created.
      *** Total elapsed time was 1 second.


     BTEQ -- Enter your SQL request orBTEQ command:
     ct t3 as (sel col2,attr1,attr2,attr3,attr4 from t1) with data;

     ct t3 as (sel col2,attr1,attr2,attr3,attr4 from t1) with data;

      *** Table has been created.
      *** Total elapsed time was 1 second.


     BTEQ -- Enter your SQL request orBTEQ command:
     sel * from t1;

     sel * from t1;

      *** Query completed. 3 rows found. 6 columns returned.
      *** Total elapsed time was 1 second.

            col1        col2       attr1       attr2       attr3       attr4
     ----------- ----------- ----------- ----------- ----------- -----------
               5           6           1           1           1           1
               3           4           1           1           1           1
               1           2           1           1           1           1

     BTEQ -- Enter your SQL request orBTEQ command:
     sel * from t2;

     sel * from t2;

      *** Query completed. 3 rows found. 5 columns returned.
      *** Total elapsed time was 1 second.

            col1        attr1        attr2        attr3        attr4
     -----------  -----------  -----------  -----------  -----------
               5            1            1            1            1
               3            1            1            1            1
               1            1            1            1            1

     BTEQ -- Enter your SQL request orBTEQ command:
     sel * from t3;

     sel * from t3;

      *** Query completed. 3 rows found. 5 columns returned.
      *** Total elapsed time was 1 second.

            col2        attr1        attr2        attr3        attr4
     -----------  -----------  -----------  -----------  -----------
               6            1            1            1            1
               4            1            1            1            1
               2            1            1            1            1

Rgds.



     
  <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