1、分组之后再合计
关键字: grouping sets ((分组字段1,分组字段2),())
select sylbdm ,count(sylbmc) as rs,round(count(sylbmc)/(select count(sylbmc) from bmk),4)*100 || '%' as bl
from bmk
GROUP BY grouping sets ((sylbdm ),())
2、显示不为空的值
关键字: coalesce合并多个字段,显示第一个不为null的值文章来源:https://www.toymoban.com/news/detail-640542.html
select COALESCE(sylbdm, '合计') as lx,
count(sylbdm) as rs,
ROUND(COUNT(sylbdm) / (select count(*) from BMK) * 100, 2) || '%' AS bl
from BMK
group by GROUPING SETS ((sylbdm), ())
文章来源地址https://www.toymoban.com/news/detail-640542.html
到了这里,关于【Oracle 数据库 SQL 语句 】积累1的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!