Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 30 Oct 2007 @ 14:47:00 GMT


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


Subj:   Re: Generate unique id
 
From:   Koripally, Sridhar

HI Soumya,

I thought of a query using HashRow and HashBucket functions.

     HASHBUCKET(HASHROW('')) = 0      - Blank Stirng
     HASHBUCKET(HASHROW()) = 65535    - null

Now, Use these combination to get unique id for fd1,fd2,fd3 like this

     Unique_id=HASHBUCKET(HASHROW(fd1))
                   * HASHBUCKET(HASHROW(fd2)) * HASHBUCKET(HASHROW(fd3))

This will give you unique values (also, this is faster as there is no aggrgation is involved) if you do not have values repeated within the fd1,fd2,fd3. That is, It give the same value for (100, 200, 300) , (300,200,100) and (200,300,100).

To get unique in this case also, use any other operation (or combination) other than only multiplication(*)

Hope this gives you hint.


Thanks,

Sridhar Koripally



     
  <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