select c.name, trunc((c.num / b.total) * 100, 2) amount
from (select b.name, a.jfdd, count(1) num
from yy a
left join xx b on b.id = a.jfdd
where a.jflx = '1'
group by b.name, a.jfdd) c,
(select count(1) total from nn) b
order by amount desc

count(1)统计表中的总记录数,

trunc(小数,需要保留几位)   对小数进行处理,根据第二位参数的值确定保留几位小数

order by  字段名 desc 从大到小排序,

order by  字段名  asc  从小到大排序

group by  字段名,根据字段进行分组,字段名一致的为一组

select c.name, trunc((c.num / b.total) * 100, 2) amount from (select b.name, a.jfdd, count(1) num from yy a left join xx b on b.id = a.jfdd where a.jflx = '1' g...