Home Page for the TeradataForum
 
https:

Archives of the TeradataForum

Message Posted: Thu, 08 Nov 2012 @ 13:37:36 GMT


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


Subj:   Re: How to generate Surrogate Key using CSUM?
 
From:   naresh.neelam

Hi Dipti Prakash,

Actaully we can use two differnet ways to generate the sequence number i.e CSUM and RANK as per my knowledge Rank is good for sequence generation...

     INSERT INTO TABLE2
     SELECT RANK() OVER(ORDER BY COLUMN1)+MAX_VAL AS SEQ_NUM
     FROM TABLE1,
     (SELECT COALESCE(MAX(SEQ_NUM),0) MAX_VAL FROM TABLE2) SEQ
     WHERE
     NOT EXISTS
     (SELECT
     1
     FROM
     TABLE2
     WHERE
     TABLE1.COLUMN1=TABLE2.COLUMN1
     )

Regards,

Naresh Neelam



     
  <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: 28 Jun 2020