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: Richard Kuhler <noone_at_nowhere.com>
Date: Thu, 11 Jul 2002 20:55:15 GMT
Message-ID: <TgmX8.71486$1D2.29424223@twister.socal.rr.com>


It's ugly but I think it works...

select curr.d, next.d - curr.d as days
from (
  select d, rownum + 1 as next_rn
  from(
    select d
    from x
    order by d
    )
  ) curr, (
  select d, rownum as rn
  from(
    select d
    from x
    order by d
    )
  ) next
where curr.next_rn = next.rn (+)

Richard

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 11 2002 - 15:55:15 CDT

Original text of this message

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