Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Calcs between two rows of same table. (NEVERMIND)
DOH! Answered my own question...
select max(MYCOUNT)-min(MYCOUNT) from MYTABLE group by round(rownum/2+.5)*2 UNION select max(MYCOUNT)-min(MYCOUNT) from MYTABLE group by round((rownum-1)/2+.5)*2
If I had just experimented 1 more minute before writing that message.... <blush>
Rich Jesse System/Database Administrator Rich.Jesse_at_qtiworld.com Quad/Tech International, Sussex, WI USA
-----Original Message-----
Sent: Monday, June 18, 2001 14:34
To: 'ORACLE-L_at_fatcity.com'
Hi all,
I've got a table, MYTABLE:
MYCOUNT number MYDATE date, UNIQUE e.g: MYCOUNT MYDATE 12509 06/17/2001 12:01 12934 06/17/2001 12:06 13452 06/17/2001 12:11 13455 06/17/2001 12:16
I need to get the difference between MYCOUNT on two consecutive rows
(consecutive MYDATEs). MYCOUNT cannot be less than the MYCOUNT
chronologically before it.
Is there a simple SELECT that I can use for this WITHOUT a cursor? I've come close:
select max(MYCOUNT)-min(MYCOUNT) from MYTABLE group by round(rownum/2+.5)*2
But this only gives me diffs from rows 1, 2-3, 4-5, 6-7, etc., while I need the diffs from rows 1-2, 2-3, 3-4, 4-5... AAAALLLMOST!
TIA,
Rich Jesse System/Database Administrator Rich.Jesse_at_qtiworld.com Quad/Tech International, Sussex, WI USA
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jesse, Rich INET: Rich.Jesse_at_qtiworld.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-LReceived on Mon Jun 18 2001 - 14:38:54 CDT
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).