postgresql分析函数

Posted 四季镇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postgresql分析函数相关的知识,希望对你有一定的参考价值。

参考:https://blog.csdn.net/haohaizijhz/article/details/83340814

SELECT uid, odate, num,
sum(num) over (),
sum(num) over (partition by uid),
sum(num) over (partition by uid,odate),
sum(num) over (order by uid,odate),
sum(num) over (order by uid,odate,num),
rank() over (partition by uid order by odate),
rank() over (partition by uid order by odate,num),
sum(num) over (partition by uid order by odate),
lead(num,1,0) OVER (partition by uid order by odate),
-num+lead(num,1,0) OVER (partition by uid order by odate),
1.0*num/sum(num) over() rate
FROM dev."order";

SELECT name, course, score,
sum(score) over (order by course rows between unbounded preceding and current row),
sum(score) over (order by course range between unbounded preceding and current row)
  FROM dev.score;

ORDER BY子句:分析函数中ORDER BY的存在将添加一个默认的开窗子句,这意味着计算中所使用的行的集合是当前分区中当前行和前面所有行;没有ORDER BY时,默认的窗口是全部的分区。

以上是关于postgresql分析函数的主要内容,如果未能解决你的问题,请参考以下文章

PostgreSQL——语义分析3——目标属性及Where子句

PostgreSql——From子句的语义分析处理

PostgreSQL——查询分析

PostgreSQL 是不是支持表(片段)的透明压缩?

Android 逆向ART 脱壳 ( DexClassLoader 脱壳 | DexClassLoader 构造函数 | 参考 Dalvik 的 DexClassLoader 类加载流程 )(代码片段

Android 逆向ART 脱壳 ( DexClassLoader 脱壳 | DexClassLoader 构造函数 | 参考 Dalvik 的 DexClassLoader 类加载流程 )(代码片段