ratio_to_report分析函数求占比
来源:互联网 发布:买岛国片在淘宝输什么 编辑:程序博客网 时间:2024/04/29 12:19
drop table test;
create table test
(
name varchar(20),
kemu varchar(20),
score number
);
insert into test values('testa','yuwen',10);
insert into test values('testa','英语',100);
insert into test values('testb','yuwen',60);
insert into test values('testb','yuwen',120);
insert into test values('testc','yuwen',40);
select name,
score,
ratio_to_report(score) over() as "占所有科目的百分比",
ratio_to_report(score) over(partition by kemu) as "占各科目的百分比"
from test ;
NAME SCORE 占所有科目的百分比 占各科目的百分比
-------------------- ---------- ------------------ ----------------
testa 10 .03030303 .043478261
testb 60 .181818182 .260869565
testc 40 .121212121 .173913043
testb 120 .363636364 .52173913
testa 100 .303030303 1
drop table test;
试想下假设我们没有这个分析函数,实现就有可能如下:
select name,score,
(score/sum(score) over()) as "占所有科目的百分比",
(score/sum(score) over(partition by kemu)) as "占所有科目的百分比"
from test
group by name,score,kemu
order by 2;
嘿嘿,还是没有那个方便,估计效率也不咋的。
总结:1. 有了ratio_to_report分析函数,我们避免了还需要写分析函数,自己相除的写法,SQL简单实现了。
2. site:download.oracle.com ratio_to_report 搜索oracle官方文档
转自:http://blog.csdn.net/ningjieshuijing/article/details/5854495
- ratio_to_report分析函数求占比
- ratio_to_report 分析函数求占比
- ratio_to_report分析函数求占比
- ratio_to_report分析函数求占比
- ratio_to_report分析函数求占比
- oracle ratio_to_report 占比函数
- oracle ratio_to_report 占比函数
- oracle 求占百分比的分析函数 ratio_to_report() over();
- Oracle SQL ratio_to_report函数、占比统计
- Oracle占比函数: oracle ratio_to_report
- oracle分析函数系列之ratio_to_report:计算占总数百分比
- ratio_to_report()分析函数
- 分析函数ratio_to_report的使用
- oracle分析函数Ratio_to_report使用说明
- 分析函数RATIO_TO_REPORT 的使用
- 分析函数ratio_to_report的使用
- oracle 求男女比例 sql 函数ratio_to_report
- 20090901_ 分析函数ratio_to_report的使用
- Cookie和Session
- servlet总结
- [论文笔记]Face Alignment by Explicit Shape Regression
- Android 初始文件夹创建 以及 文件&文件夹相关操作
- Android适配底部虚拟按键的方法
- ratio_to_report分析函数求占比
- iOS应用之微信支付集成
- 使用Redis sorted set实现集合设置member过期
- 机器人走方格
- 06-图3 六度空间 (30分)
- 一个android手写板的例子
- 函数 _CrtSetBreakAlloc()使用blog
- 前端框架Vue(6)——Vue 介绍和相关操作
- Android报错:JNI/NDK相关