| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.oracle -> Re: sql - statement: building differences between data-sets
Try Analytic functions.
(As Tom Kyte would say: 'Analytics Rock').
An alternative is a join like this:
select 2.id ID, (2.value - nvl(1.value,0)) diff
from table 1, table 2
where 2.id - 1 = 1.id (+)
Cheers.
Carlos.
rudi.ramstein_at_gmx.de (beyond) wrote in message news:<621ad8ac.0408031217.41fc6fc3_at_posting.google.com>...
> i need a sql-statement for this problem
>
> i ve got a table like this
> ID;value
> 1;30
> 2;34
> 3;44
>
> the result of sql-statement should calculate differences to
> previous/other datasets like this
> ID;diff
> 1; 30-0
> 2; 34-30
> 3; 44-34
>
> who can solve this problem elegant?
Received on Wed Aug 04 2004 - 02:14:29 CDT
![]() |
![]() |