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

Home -> Community -> Usenet -> c.d.o.server -> Re: Need help with SQL

Re: Need help with SQL

From: Martin Haltmayer <Martin.Haltmayer_at_d2mail.de>
Date: Thu, 18 Jul 2002 16:46:13 +0200
Message-ID: <3D36D4B5.CEF439FD@d2mail.de>

SQL> select     p.d
  2          , l.d - p.d
  3  from       leadtest l
  4          , leadtest p
  5  where      1 = 1
  6  and        l.d (+) > p.d
  7  and        not exists (
  8          select  null
  9          from    leadtest u
 10          where   1 = 1
 11          and     l.d > u.d
 12          and     u.d > p.d
 13          and     rownum <= 1	-- just for tuning
 14 )
 15 order by l.d
 16 ;
07/01/2002          2
07/03/2002          1
07/04/2002          4
07/08/2002          1
07/09/2002          2
07/11/2002

Regards,

Martin

Philip Kuan wrote:
>
> Hi All,
>
> We are using Oracle 8.
>
> I have a table like this:
>
> Ernty_Time
> ----------
> 7/1/2002
> 7/3/2002
> 7/4/2002
> 7/8/2002
> 7/9/2002
> 7/11/2002
>
> The query results should look like this:
>
> Entry_Time Value (next entry_time - previous entry_time)
> ---------- -----
> 7/1/2002 2
> 7/3/2002 1
> 7/4/2002 4
> 7/8/2002 1
> 7/9/2002 2
> 7/11/2002
>
> Since we are using Oracle 8 I cannot use LEAD analytic function
> provided in 8i and 9i. There is no ID column as well.
>
> I appreciate any help. Thank you in advance.
>
> Philip Kuan
Received on Thu Jul 18 2002 - 09:46:13 CDT

Original text of this message

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