create table temp_david(wh varchar2(100))
insert into temp_david values('大學')
insert into temp_david values('大學')
insert into temp_david values('大學')
insert into temp_david values('大專')
insert into temp_david values('大專')
insert into temp_david values('高中')
insert into temp_david values('高中')
insert into temp_david values('初中')
insert into temp_david values('初中')
insert into temp_david values('初中')
select count(*) all_count,
sum(case when wh ='大學' then 1 else 0 end) as "大學",
round(sum(case when wh ='大學' then 1 else 0 end)/count(*),3)*100||'%' as "大學比例",
sum(case when wh ='大專' then 1 else 0 end) as "大專",
round(sum(case when wh ='大專' then 1 else 0 end)/count(*),3)*100||'%' as "大專比例",
sum(case when wh ='高中' then 1 else 0 end) as "高中",
round(sum(case when wh ='高中' then 1 else 0 end)/count(*),3)*100||'%' as "高中比例",
sum(case when wh ='初中' then 1 else 0 end) as "初中",
round(sum(case when wh ='初中' then 1 else 0 end)/count(*),3)*100||'%' as "初中比例"
from temp_david