Calculating percentages
785040Sep 7 2010 — edited Sep 7 2010Hey 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!