-
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
-
Increase the number of decimal places on your percent column ?
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|