SQL> select num,count(*),RATIO_TO_REPORT(count(*)) over() Percent from test1 GROUP BY num; NUM COUNT(*) PERCENT
---------- ---------- ----------
1 1 0.1
2 3 0.3
3 2 0.2
4 2 0.2
5 1 0.1
8 1 0.16 rows selected
---------- ---------- ----------
1 1 0.1
2 3 0.3
3 2 0.2
4 2 0.2
5 1 0.1
8 1 0.16 rows selected
select age,count(*) as counter,RATIO_TO_REPORT(count(*)) over() as Percent from student GROUP BY age order by counter desc
|| '%' AS percent
FROM (SELECT AGE, COUNT(*) AS COU, MAX
((SELECT COUNT(*)
FROM student)) AS COU_ALL
FROM student
GROUP BY AGE) A