Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Urgent! Programming Question ,(value of current date/value of prior date)
Coca wrote:
> Hi all,
>
> I am working on a project using Oracle9i
> and encounted a question as belows:
>
> A Table like this:
>
> create table account (sdate date,svalue numeric(16,2))
>
> ======
> some records like:
> sdate svalue
>
> 2003-1-1 2000
> 2003-2-1 3000
> 2003-3-1 3200
> 2003-4-1 1400
> 2003-5-1 2500
> 2003-6-1 2400
>
>
> The records of the table follow this rule: only one record for one month,
> that is, each month has only one record.
>
> The end-user could select any period of date as he will, such as from
> 2003-1-1 to 2003-4-1,
> and my progrom should calculate a financial indicator called indicator1
> whose formula is:
> (value of current date/value of prior date), that is
>
> sdate svalue indicator1
>
> 2003-1-1 2000 null(since the value of 2002-12-1 does not exist in the
> table)
> 2003-2-1 3000 3000/2000=1.5
> 2003-3-1 3200 3200/3000=1.067
> 2003-4-1 1400 1400/3200=0.4375
> ...
>
> How can I do this using one sql sentence,not a stored procedure.
>
> Any tips are appreciated.
>
> Thank you.
>
> Coca
Which school, class & instructor gave you this homework assignment? First solve it for one set of hard coded values & then extrapolate. Received on Thu Dec 25 2003 - 11:00:51 CST
![]() |
![]() |