DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Apportionment of value to 100

  1. #1
    Join Date
    Jun 2005
    Posts
    20

    Apportionment of value to 100

    Hi SQL/PL/sql Math Gurus,

    I need a valid approtionment logic to solve my problem.
    I need to plot a pie chart based oracle data.

    My scenario is

    create table app(grp varchar2(1),value number, perc number(4,1));

    select * from app;

    G VALUE
    - ----------
    A 696
    B 268
    C 136


    update app set perc = value/(select sum(value) from app);

    hr@ENCOVER> select * from app;

    G VALUE PERC
    - ---------- ----------
    A 696 .6
    B 268 .2
    C 136 .1

    while summing the same it give .9 (.6 + .2 + .1)

    i need to logic in such a way will approtion properly so that i can get as 1.

    pl. let me know how to resolve this

  2. #2
    Join Date
    Nov 2001
    Location
    UK
    Posts
    152
    Increase the number of decimal places on your percent column ?

  3. #3
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Try this:

    Code:
    
      1  select grp, value ,
      2         ratio_to_report(value) over () rr
      3* from app
    SQL> /
    
    G      VALUE         RR
    - ---------- ----------
    A        696 .632727273
    B        268 .243636364
    C        136 .123636364
    Tamil
    www.beaconinfotechcorp.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width