Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: sql question
No error handling, col1, col2 and col3 must all be there and be unique
and so on...
SQL> SELECT col1, col2, (s - k / p) AS "wrong formula", (s - k) / p AS
"correct formula"
2 FROM (SELECT col1, col2, col3, LEAD(val) OVER(ORDER BY col1,
col3) AS s,
3 LAG(val) OVER(ORDER BY col1, col3) AS k, val AS p 4 FROM t 5 ORDER BY col1, col3)
COL1 COL2 wrong formula correct formula ---------- ---------- ------------- ---------------
1 2 43 -,92857143 4 5 94,5 ,681818182
Hth, Urs Received on Wed May 25 2005 - 07:04:29 CDT