The table name is emp(many fields) with 'designation' as 1 field. my query is i want the percentage of "MANAGERS" in that emp table. (suppose there are 14 rows in total, the rows with 'managers' are 3, so output is (3/14)*100 ).

Questions by ashwin.k

Showing Answers 1 - 13 of 13 Answers

Maheshwar Singh

  • May 29th, 2006
 

I think we cannot do it with a single SQL statement we need either a procedure to do it or we can use a function using Pl-Sql.if there is any other way please tell it to me also.

  Was this answer useful?  Yes

Anil Kumar Desu

  • May 29th, 2006
 

SELECT m/a*100 FROM (SELECT COUNT(*) m FROM emp WHERE DESIGNATION='MANAGER'), (SELECT COUNT(DESIGNATION) A FROM emp)I think this will suffice your requirement. For further clarification you can reach me on to desuanil@gmail.comAnil Kumar.D

  Was this answer useful?  Yes

Dhayanand D

  • May 29th, 2006
 

We need to wrtie a procedure to accomplish the task.

  Was this answer useful?  Yes

Dhruba Guha

  • Nov 2nd, 2006
 

Hello dear,

For that above query you can try in that way ..........

Select (
(select count(rownum) from emp where post= 'man')/(select count(rownum) from emp)
)*100 as percentage
from dual

Regards

Dhruba

  Was this answer useful?  Yes

seema

  • Nov 9th, 2006
 

 select count(decode(designation,'Manager',1))/count(*)*100 from emp;

  Was this answer useful?  Yes

Vijay

  • Feb 16th, 2007
 

Above query will work but you have to take care of division by zero error.You can use this also SELECT (mag_count/total_count)*100 percentage FROM (SELECT COUNT(*) mag_count FROM emp WHERE desg='MANG'),(SELECT COUNT(*) total_count FROM emp)WHERE total_count <> 0or select count(decode(desg,'Manager',1,0))/count(*)*100 from empHAVING COUNT(*)<>0

  Was this answer useful?  Yes

sudeep

  • Mar 29th, 2007
 

hi...


select (count(distinct mgr)/count(*) * 100) from emp;

Rgds,
deeps..

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions