Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:23:37+00:00 2026-06-05T22:23:37+00:00

I am a bit stuck on one problem for a few hours now. Let`s

  • 0

I am a bit stuck on one problem for a few hours now.

Let`s say I have a table with the following data:

month          outstanding
01/05/2012     35 678 956
02/05/2012     33 678 956
03/05/2012     31 678 956
04/05/2012     27 678 956
05/05/2012     24 678 956

i need to get the ratio of say, day 05/05/2012 results to the first day of that month
E.G. Outstanding of05/05/2012 divided by outstanding 01/05/2012 (24 678 956/35 678 956)

What function should i use?
Tried doing over partition by / by result of to_char(trunc(trunc(a.date_,’MM’), ‘MM’),’DD-MM-YYYY’)

Didnt seem to work for me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:23:38+00:00Added an answer on June 5, 2026 at 10:23 pm
    create table temp (month date , outstanding number);
    insert into temp values(to_date('01/05/2012','dd/mm/yyyy'),35678956);
    insert into temp values(to_date('02/05/2012','dd/mm/yyyy'),33678956);
    insert into temp values(to_date('03/05/2012','dd/mm/yyyy'),31678956);
    insert into temp values(to_date('04/05/2012','dd/mm/yyyy'),27678956);
    insert into temp values(to_date('05/05/2012','dd/mm/yyyy'),24678956);
    insert into temp values(to_date('01/06/2012','dd/mm/yyyy'),44678956);
    insert into temp values(to_date('02/06/2012','dd/mm/yyyy'),41678956);
    

    The FIRST_VALUE analytic function picks the first record from the partition after doing the ORDER BY

    SELECT month
          ,outstanding
          ,outstanding/(FIRST_VALUE(outstanding)
                 OVER (PARTITION BY to_char(month,'mm') 
                 ORDER BY month
            )) as ratio
    FROM temp
    ORDER BY month;
    

    OUTPUT

    MONTH     OUTSTANDING      RATIO
    --------- ----------- ----------
    01-MAY-12    35678956          1
    02-MAY-12    33678956 .943944548
    03-MAY-12    31678956 .887889096
    04-MAY-12    27678956 .775778193
    05-MAY-12    24678956 .691695015
    01-JUN-12    44678956          1
    02-JUN-12    41678956 .932854295
    

    7 rows selected.

    SQLFIDDLE link

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am little bit stuck with the following problem. I have two models: class
I'm a little bit stuck with the following problem: I would like all my
I'm stuck with a bit of a problem here. I'm importing data from a
I haven't implemented a search feature before and feel a bit stuck. I have
I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck
I have a bit of a problem with my PHP code, I am assigning
I have a problem running Selenium IDE over one of my AJAX pages. There
I'm running into a problem because my database has BIGINT data (64-bit integers) but
I'm a bit stuck with a problem. I feel like the solution should be
I have a legacy ASP.NET site I'd like to improve a bit. One area

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.