vertica sql delta -


i want calculate delta value between 2 records table got 2 column id , timestamp want calculate delta time between records

    id  |timestamp |delta ----------------------------------     1   |100       |0     2   |101       |1 (101-100)     3   |106       |5 (106-101)     4   |107       |1 (107-106) 

i work vertica data base , want create view/projection of table on db.

is possible create calculate without using udf function?

you can use lag() purpose:

select id, timestamp,        coalesce(timestamp - lag(timestamp) on (order id), 0) delta t; 

Comments

Popular posts from this blog

How to use SUM() in MySQL for calculated values -

ios - IBOutlet for image button not correctly referencing button after recreating outlet -

java - AEM: 403 Forbidden occurs when call a Post servlet -