Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Calcs between two rows of same table.

Calcs between two rows of same table.

From: Jesse, Rich <Rich.Jesse_at_qtiworld.com>
Date: Mon, 18 Jun 2001 12:18:24 -0700
Message-ID: <F001.0032DBB1.20010618123102@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-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Mon Jun 18 2001 - 14:18:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US