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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Find rows with a change in a field compared with the previous row

Re: Find rows with a change in a field compared with the previous row

From: Carlos <miotromailcarlos_at_netscape.net>
Date: 6 Jun 2005 08:02:07 -0700
Message-ID: <1118069098.506915.166390@g14g2000cwa.googlegroups.com>

SQL> SELECT SESSION_ID, DECODE(LIGHT_ON,'N','OFF','ON') STATUS
  2  FROM ( SELECT SESSION_ID, LIGHT_ON, LAG(LIGHT_ON) OVER (ORDER BY
SESSION_ID) AS PREV_LIGHT_ON FROM MY_TABLE )
  3 WHERE LIGHT_ON != PREV_LIGHT_ON
  4 /

SESSION_ID STATUS
---------- ---

         5 OFF
         8 ON
        14 OFF

SQL> Received on Mon Jun 06 2005 - 10:02:07 CDT

Original text of this message

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