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: Oracle SQL query to check off and compare of previous record

Re: Oracle SQL query to check off and compare of previous record

From: Daniel Roy <danielroy10junk_at_hotmail.com>
Date: 6 Aug 2003 11:36:56 -0700
Message-ID: <3722db.0308061036.1a461f2d@posting.google.com>


Interesting homework :-)
Please define "previous". How are we supposed to order the records? Please read about the analytic functions.

Daniel

> Is it possible to do an SQL looking at InvNumber and comparing the
> previous record to see if that previous record has the same invoice
> number and return the result 1 in the current line. For example:
>
> Invoice table
> Name InvNo
> ----- -----
> john 1
> bob 2
> jane 2
> ralph 3
> ken 4
> tom 4
>
> The result of the SQL would be
> Name InvNo Prevtrue
> ----- ----- --------
> john 1 0
> bob 2 0
> jane 2 1
> ralph 3 0
> ken 4 0
> tom 4 1
>
> Any posts or comments that can help in this matter would be
> appreciated.
>
> Thanks,
> Dave
Received on Wed Aug 06 2003 - 13:36:56 CDT

Original text of this message

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