Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Retrive values from different rows
On Jun 17, 9:27 am, sviluppo..._at_gmail.com wrote:
> In other words this must be the result:
> ID ART QTA REASON VAL
> 1 A 10 W 10
> 2 A -2 C 8
> 3 A 3 PO 11
> 4 A -4 C 7
> 5 B 5 W 5
> 6 B -2 C 3
> 7 B -4 C -1
> 8 B 5 PO 4
> 9 C 5 W 5
> 10 D 7 W 7
I'm not quite following this.
Is ID supposed to state the order of the records? If so:
SELECT ID, art, qta, reason
, CASE WHEN reason = 'W' THEN qta ELSE (SELECT SUM (qta) FROM thetable WHERE art = t.art AND ID <= t.ID) END AS val
Good luck. Received on Sun Jun 17 2007 - 21:33:42 CDT