Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Sat, 11 Feb 2012 @ 10:18:19 GMT

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

Subj:   Re: Adding intervals dynamically.
From:   Dieter Noeth

sivaram nelluri wrote:

  I have multiple records at the same time, Ex: 100 records with same time including the milli seconds too, I am trying to stretch each of them into separate timestamps by adding a random number of seconds or milli seconds  

     + (row_number() over(partition by record_timestamp order by record_id)
         * interval '0.000001' second)

I use this approach with current_timestamp to get a specific order when inserting multiple rows in a queue table.

If you don't care about the actual order and possible duplicates you might also use random(0,999999) instead of row_number, it's less overhead.


  <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