Re: sql - statement: building differences between data-sets
From: Carlos <miotromailcarlos_at_netscape.net>
Date: 4 Aug 2004 00:14:29 -0700
Message-ID: <1de5ebe7.0408032314.1a60c0e_at_posting.google.com>
Date: 4 Aug 2004 00:14:29 -0700
Message-ID: <1de5ebe7.0408032314.1a60c0e_at_posting.google.com>
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 - 09:14:29 CEST