Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Calculating percentages

785040Sep 7 2010 — edited Sep 7 2010
Hey all, using 11g r2 enterprise here.


I need to calculate a percentage of certain values from the total number of rows on a table. Here are the two queries for that:

SELECT COUNT(*) FROM table WHERE employee='Bob' AND TYPE='1'; -- Get the # of Type 1 Records for Bob

SELECT COUNT(*) FROM table WHERE employee='Bob'; -- Get total of Bob's Records
The percentage should be (Type 1)/(Total Records).

I've done a lot of searching and I've seen a lot of tutorials on advanced percentages and joining tables and such; I really don't need that here, I just need a way to calculate those two queries into a percentage (or whatever is the most effecient way to get my results).

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2010
Added on Sep 7 2010
12 comments
3,619 views