[TOC]
# <span style="font-size:15px">**通用聚合函数**</span>
<table border="0">
<tbody>
<tr>
<td><span style="font-family: "courier new", courier">函数</span></td>
<td><span style="font-family: "courier new", courier">参数类型</span></td>
<td><span style="font-family: "courier new", courier">返回类型</span></td>
<td><span style="font-family: "courier new", courier">描述</span></td>
<td><span style="font-family: "courier new", courier">示例</span></td>
<td><span style="font-family: "courier new", courier">结果</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">array_agg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">任意非数组类型</span></td>
<td><span style="font-family: "courier new", courier">参数类型的数组</span></td>
<td><span style="font-family: "courier new", courier">将入参包括NULL连接成一个数组</span></td>
<td><span style="font-family: "courier new", courier">select array_agg(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">{1,2,3}</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">array_agg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">任意数组类型</span></td>
<td><span style="font-family: "courier new", courier">入参数据类型</span></td>
<td>
<p><span style="font-family: "courier new", courier">将入参数组连接成更高维度的数组,输入的数组必须是相同</span><span style="font-family: "courier new", courier">的维度,且不允许是空或NULL</span></p>
</td>
<td><span style="font-family: "courier new", courier">select array_agg(array['b','c','a']);</span></td>
<td><span style="font-family: "courier new", courier"> {{b,c,a}}</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">avg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span class="Apple-tab-span" style="font-family: "courier new", courier"> smallint, int, bigint, real, double precision, numeric, or interval</span></td>
<td><span style="font-family: "courier new", courier">整形返回numeric,浮点型返回double precision,其他和入参类型相同</span></td>
<td><span style="font-family: "courier new", courier">平均值</span></td>
<td><span style="font-family: "courier new", courier">select avg(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2.0000000000000000</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">bit_and(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier"><tt class="TYPE">smallint</tt>, <tt class="TYPE">int</tt>, <tt class="TYPE">bigint</tt>, or <tt class="TYPE">bit</tt></span></td>
<td><span style="font-family: "courier new", courier">和入参类型相同</span></td>
<td><span style="font-family: "courier new", courier">所有非NULL输入值的按位与,如果全为NULL则返回NULL</span></td>
<td><span style="font-family: "courier new", courier">select bit_and(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">bit_or(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier"><tt class="TYPE">smallint</tt>, <tt class="TYPE">int</tt>, <tt class="TYPE">bigint</tt>, or <tt class="TYPE">bit</tt></span></td>
<td><span style="font-family: "courier new", courier">和入参类型相同</span></td>
<td><span style="font-family: "courier new", courier">所有非NULL输入值的按位或,如果全为NULL则返回NULL</span></td>
<td><span style="font-family: "courier new", courier">select bit_or(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">bool_and(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">如果输入全是true则返回true,否则为false</span></td>
<td><span style="font-family: "courier new", courier">select bool_or(id::bool) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">t</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">bool_or(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">如果输入至少一个true,则返回true,否则返回false</span></td>
<td><span style="font-family: "courier new", courier">select bool_or((id-1)::bool) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">t</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">count(*)</span></td>
<td> </td>
<td><span style="font-family: "courier new", courier">bigint</span></td>
<td><span style="font-family: "courier new", courier">输入行数</span></td>
<td><span style="font-family: "courier new", courier">select count(*) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">count(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">any</span></td>
<td><span style="font-family: "courier new", courier">bigint</span></td>
<td><span style="font-family: "courier new", courier">输入行中非NULL的行数</span></td>
<td><span style="font-family: "courier new", courier">select count(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">every(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">bool</span></td>
<td><span style="font-family: "courier new", courier">功能同bool_and</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">json_agg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">any</span></td>
<td><span style="font-family: "courier new", courier">json</span></td>
<td><span style="font-family: "courier new", courier">将输入聚合成一个json数组</span></td>
<td><span style="font-family: "courier new", courier">select json_agg(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">[1, 2, 3]</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">jsonb_agg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">any</span></td>
<td><span style="font-family: "courier new", courier">jsonb</span></td>
<td><span style="font-family: "courier new", courier">将输入聚合成一个json数组</span></td>
<td><span style="font-family: "courier new", courier">select jsonb_agg(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">[1, 2, 3]</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">json_object_agg(<tt class="REPLACEABLE c3">name</tt>,<tt class="REPLACEABLE c3">value</tt>)</span></td>
<td><span style="font-family: "courier new", courier">(any, any)</span></td>
<td><span style="font-family: "courier new", courier">json</span></td>
<td><span style="font-family: "courier new", courier">将输入组成一个key/value对的json对象</span></td>
<td><span style="font-family: "courier new", courier">select json_object_agg('a','one');</span></td>
<td><span style="font-family: "courier new", courier">{ "a" : "one" }</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">jsonb_object_agg(<tt class="REPLACEABLE c3">name</tt>,<tt class="REPLACEABLE c3">value</tt>)</span></td>
<td><span style="font-family: "courier new", courier">(any, any)</span></td>
<td><span style="font-family: "courier new", courier">jsonb</span></td>
<td><span style="font-family: "courier new", courier">将输入组成一个key/value对的json对象</span></td>
<td><span style="font-family: "courier new", courier">select jsonb_object_agg('a','one');</span></td>
<td><span style="font-family: "courier new", courier">{"a": "one"}</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">max(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td> </td>
<td> </td>
<td><span style="font-family: "courier new", courier">输入最大值</span></td>
<td>
<p><span style="font-family: "courier new", courier">select max(id) from tbl_test;</span></p>
</td>
<td><span style="font-family: "courier new", courier">3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">min(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td> </td>
<td> </td>
<td><span style="font-family: "courier new", courier">输入最小值</span></td>
<td><span style="font-family: "courier new", courier">select min(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">string_agg(<tt class="REPLACEABLE c3">expression</tt>,<tt class="REPLACEABLE c3">delimiter</tt>)</span></td>
<td><span style="font-family: "courier new", courier">(<tt class="TYPE">text</tt>, <tt class="TYPE">text</tt>) or (<tt class="TYPE">bytea</tt>, <tt class="TYPE">bytea</tt>)</span></td>
<td><span style="font-family: "courier new", courier">同参数类型</span></td>
<td><span style="font-family: "courier new", courier">将输入使用delimiter连接成一个text</span></td>
<td><span style="font-family: "courier new", courier">select string_agg(name,',') from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier"> 张三,李四,王五</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">sum(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier"><tt class="TYPE">smallint</tt>, <tt class="TYPE">int</tt>, <tt class="TYPE">bigint</tt>, <tt class="TYPE">real</tt>, <tt class="TYPE">double precision</tt>, <tt class="TYPE">numeric</tt>, <tt class="TYPE">interval</tt>, or <tt class="TYPE">money</tt></span></td>
<td> </td>
<td><span style="font-family: "courier new", courier">输入和</span></td>
<td><span style="font-family: "courier new", courier">select sum(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">6</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">xmlagg(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">xml</span></td>
<td><span style="font-family: "courier new", courier">xml</span></td>
<td> </td>
<td><span style="font-family: "courier new", courier">请参考xml类型及其函数</span></td>
<td> </td>
</tr>
</tbody>
</table>
# <span style="font-size:15px">**统计聚合函数**</span>
<table border="0">
<tbody>
<tr>
<td><span style="font-family: "courier new", courier">函数</span></td>
<td><span style="font-family: "courier new", courier">参数类型</span></td>
<td><span style="font-family: "courier new", courier">返回类型</span></td>
<td><span style="font-family: "courier new", courier">描述</span></td>
<td><span style="font-family: "courier new", courier">示例</span></td>
<td><span style="font-family: "courier new", courier">结果</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">corr(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">相关系数</span></td>
<td><span style="font-family: "courier new", courier">select corr(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">covar_pop(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">总体协方差</span></td>
<td><span style="font-family: "courier new", courier">select covar_pop(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0.666666666666667</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">covar_samp(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">样本协方差</span></td>
<td><span style="font-family: "courier new", courier">select covar_samp(id,id1) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_avgx(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">自变量平均值(sum(X)/N)</span></td>
<td><span style="font-family: "courier new", courier">select regr_avgx(id,id1) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_avgy(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">因变量平均值(sum(Y)/N)</span></td>
<td><span style="font-family: "courier new", courier">select regr_avgy(id,id1) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_count(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">bigint</span></td>
<td><span style="font-family: "courier new", courier">两个参数都不为NULL的行数</span></td>
<td><span style="font-family: "courier new", courier"> select regr_count(id,id1) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">3</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_intercept(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">根据所有输入点(X,Y)利用最小二乘法计算一个线性方程式。然后返回该直线的Y轴截距</span></td>
<td><span style="font-family: "courier new", courier">select regr_intercept(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_r2(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">相关系数平方</span></td>
<td><span style="font-family: "courier new", courier">select regr_r2(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_slope(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">根据所有输入点(X,Y)利用最小二乘法计算一个线性方程式。然后返回该直线的斜率</span></td>
<td><span style="font-family: "courier new", courier">select regr_slope(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_sxx(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier"><tt class="LITERAL">sum(<tt class="REPLACEABLE c3">X</tt>^2) - sum(<tt class="REPLACEABLE c3">X</tt>)^2/<tt class="REPLACEABLE c3">N</tt></tt> </span></td>
<td><span style="font-family: "courier new", courier">select regr_sxx(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_sxy(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier"><tt class="LITERAL">sum(<tt class="REPLACEABLE c3">X</tt>*<tt class="REPLACEABLE c3">Y</tt>) - sum(<tt class="REPLACEABLE c3">X</tt>) * sum(<tt class="REPLACEABLE c3">Y</tt>)/<tt class="REPLACEABLE c3">N</tt></tt> </span></td>
<td><span style="font-family: "courier new", courier">select regr_sxy(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">regr_syy(<tt class="REPLACEABLE c3">Y</tt>, <tt class="REPLACEABLE c3">X</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier"><tt class="LITERAL">sum(<tt class="REPLACEABLE c3">Y</tt>^2) - sum(<tt class="REPLACEABLE c3">Y</tt>)^2/<tt class="REPLACEABLE c3">N</tt></tt> </span></td>
<td><span style="font-family: "courier new", courier">select regr_syy(id,id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">stddev(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real,</span></p>
<p><span style="font-family: "courier new", courier"> double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments, </span></p>
<p><span style="font-family: "courier new", courier">otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">同stddev_samp</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">stddev_pop(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real,</span></p>
<p><span style="font-family: "courier new", courier"> double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments,</span></p>
<p><span style="font-family: "courier new", courier"> otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">总体标准差</span></td>
<td><span style="font-family: "courier new", courier">select stddev_pop(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0.81649658092772603273</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">stddev_samp(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real,</span></p>
<p><span style="font-family: "courier new", courier"> double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments, </span></p>
<p><span style="font-family: "courier new", courier">otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">样本标准差</span></td>
<td><span style="font-family: "courier new", courier">select stddev_samp(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1.00000000000000000000</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier"><code class="FUNCTION">variance</code>(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real, </span></p>
<p><span style="font-family: "courier new", courier">double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments,</span></p>
<p><span style="font-family: "courier new", courier"> otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">同var_samp</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier"><code class="FUNCTION">var_pop</code>(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real, </span></p>
<p><span style="font-family: "courier new", courier">double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments, </span></p>
<p><span style="font-family: "courier new", courier">otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">总体方差</span></td>
<td><span style="font-family: "courier new", courier">select var_pop(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">0.66666666666666666667</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier"><code class="FUNCTION">var_samp</code>(<tt class="REPLACEABLE c3">expression</tt>)</span></td>
<td>
<p><span style="font-family: "courier new", courier">smallint, int, bigint, real, </span></p>
<p><span style="font-family: "courier new", courier">double precision, or numeric</span></p>
</td>
<td>
<p><span style="font-family: "courier new", courier">double precision for floating-point arguments, </span></p>
<p><span style="font-family: "courier new", courier">otherwise numeric</span></p>
</td>
<td><span style="font-family: "courier new", courier">样本方差</span></td>
<td><span style="font-family: "courier new", courier">select var_samp(id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1.00000000000000000000</span></td>
</tr>
</tbody>
# <span style="font-size:15px">**顺序集聚合函数**</span>
<table border="0">
<tbody>
<tr>
<td><span style="font-family: "courier new", courier">函数</span></td>
<td><span style="font-family: "courier new", courier">直接参数类型</span></td>
<td><span style="font-family: "courier new", courier">聚合参数类型</span></td>
<td><span style="font-family: "courier new", courier">返回类型</span></td>
<td><span style="font-family: "courier new", courier">描述</span></td>
<td><span style="font-family: "courier new", courier">示例</span></td>
<td><span style="font-family: "courier new", courier">结果</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">mode() WITHIN GROUP (ORDER BY<tt class="REPLACEABLE c3">sort_expression</tt>)</span></td>
<td> </td>
<td><span style="font-family: "courier new", courier">任意可排序类型</span></td>
<td><span style="font-family: "courier new", courier">同排序类型</span></td>
<td>
<p><span style="font-family: "courier new", courier">返回最频繁的输入值(如果有</span></p>
<p><span style="font-family: "courier new", courier">多个同样频繁的结果,则返回第一个)</span></p>
</td>
<td><span style="font-family: "courier new", courier">select mode() within group (order by id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">2</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">percentile_cont(<tt class="REPLACEABLE c3">fraction</tt>) WITHIN GROUP (ORDER BY <tt class="REPLACEABLE c3">sort_expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier"><tt class="TYPE">double precision</tt>or <tt class="TYPE">interval</tt></span></td>
<td><span style="font-family: "courier new", courier">同排序类型</span></td>
<td><span style="font-family: "courier new", courier">continuous percentile: returns a value corresponding to the specified fraction in the ordering, interpolating between adjacent input items if needed</span></td>
<td><span style="font-family: "courier new", courier">select percentile_cont(0.25) WITHIN GROUP (ORDER BY id) from tbl_test;</span></td>
<td><span style="font-family: "courier new", courier">1.75</span></td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">percentile_cont(<tt class="REPLACEABLE c3">fractions</tt>) WITHIN GROUP (ORDER BY <tt class="REPLACEABLE c3">sort_expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision[]</span></td>
<td><span style="font-family: "courier new", courier"><tt class="TYPE">double precision</tt>or <tt class="TYPE">interval</tt></span></td>
<td><span style="font-family: "courier new", courier">array of sort expression's type</span></td>
<td><span style="font-family: "courier new", courier">multiple continuous percentile: returns an array of results matching the shape of the <tt class="LITERAL">fractions</tt>parameter, with each non-null element replaced by the value corresponding to that percentile</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">percentile_disc(<tt class="REPLACEABLE c3">fraction</tt>) WITHIN GROUP (ORDER BY <tt class="REPLACEABLE c3">sort_expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision</span></td>
<td><span style="font-family: "courier new", courier">any sortable type</span></td>
<td><span style="font-family: "courier new", courier">same as sort expression</span></td>
<td><span style="font-family: "courier new", courier">discrete percentile: returns the first input value whose position in the ordering equals or exceeds the specified fraction</span></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><span style="font-family: "courier new", courier">percentile_disc(<tt class="REPLACEABLE c3">fractions</tt>) WITHIN GROUP (ORDER BY <tt class="REPLACEABLE c3">sort_expression</tt>)</span></td>
<td><span style="font-family: "courier new", courier">double precision[]</span></td>
<td><span style="font-family: "courier new", courier">any sortable type</span></td>
<td><span style="font-family: "courier new", courier">array of sort expression's type</span></td>
<td><span style="font-family: "courier new", courier">multiple discrete percentile: returns an array of results matching the shape of the fractions parameter, with each non-null element replaced by the input value corresponding to that percentile</span></td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</table>
- PHP
- PHP基础
- PHP介绍
- 如何理解PHP是弱类型语言
- 超全局变量
- $_SERVER详解
- 字符串处理函数
- 常用数组函数
- 文件处理函数
- 常用时间函数
- 日历函数
- 常用url处理函数
- 易混淆函数区别(面试题常见)
- 时间戳
- PHP进阶
- PSR规范
- RESTFUL规范
- 面向对象
- 三大基本特征和五大基本原则
- 访问权限
- static关键字
- static关键字
- 静态变量与普通变量
- 静态方法与普通方法
- const关键字
- final关键字
- abstract关键字
- self、$this、parent::关键字
- 接口(interface)
- trait关键字
- instanceof关键字
- 魔术方法
- 构造函数和析构函数
- 私有属性的设置获取
- __toString()方法
- __clone()方法
- __call()方法
- 类的自动加载
- 设计模式详解
- 关于设计模式的一些建议
- 工厂模式
- 简单工厂模式
- 工厂方法模式
- 抽象工厂模式
- 区别和适用范围
- 策略模式
- 单例模式
- HTTP
- 定义
- 特点
- 工作过程
- request
- response
- HTTP状态码
- URL
- GET和POST的区别
- HTTPS
- session与cookie
- 排序算法
- 冒泡排序算法
- 二分查找算法
- 直接插入排序算法
- 希尔排序算法
- 选择排序算法
- 快速排序算法
- 循环算法
- 递归与尾递归
- 迭代
- 日期相关的类
- DateTimeInterface接口
- DateTime类
- DateTimeImmutable类
- DateInterval类
- DateTimeZone类
- DatePeriod类
- format参数格式
- DateInterval的format格式化参数
- 预定义接口
- ArrayAccess(数组式访问)接口
- Serializable (序列化)接口
- Traversable(遍历)接口
- Closure类
- Iterator(迭代器)接口
- IteratorAggregate(聚合迭代器) 接口
- Generator (生成器)接口
- composer
- composer安装与使用
- python
- python3执行tarfile解压文件报错:tarfile.ReadError:file could not be opened successfully
- golang
- 单元测试
- 单元测试框架
- Golang内置testing包
- GoConvey库
- testify库
- 打桩与mock
- GoMock框架
- Gomonkey框架
- HTTP Mock
- httpMock
- mux库/httptest
- 数据库
- MYSQL
- SQL语言的分类
- 事务(重点)
- 索引
- 存储过程
- 触发器
- 视图
- 导入导出数据库
- 优化mysql数据库的方法
- MyISAM与InnoDB区别
- 外连接、内连接的区别
- 物理文件结构
- PostgreSQL
- 编译安装
- pgsql常用命令
- pgsql应用目录(bin目录)文件结构解析
- pg_ctl
- initdb
- psql
- clusterdb
- cluster命令
- createdb
- dropdb
- createuser
- dropuser
- pg_config
- pg_controldata
- pg_checksums
- pgbench
- pg_basebackup
- pg_dump
- pg_dumpall
- pg_isready
- pg_receivewal
- pg_recvlogical
- pg_resetwal
- pg_restore
- pg_rewind
- pg_test_fsync
- pg_test_timing
- pg_upgrade
- pg_verifybackup
- pg_archivecleanup
- pg_waldump
- postgres
- reindexdb
- vacuumdb
- ecpg
- pgsql数据目录文件结构解析
- pgsql数据目录文件结构解析
- postgresql.conf解析
- pgsql系统配置参数说明
- pgsql索引类型
- 四种索引类型解析
- 索引之ctid解析
- 索引相关操作
- pgsql函数解析
- pgsql系统函数解析
- pgsql窗口函数解析
- pgsql聚合函数解析
- pgsql系统表解析
- pg_stat_all_indexes
- pg_stat_all_tables
- pg_statio_all_indexes
- pg_statio_all_tables
- pg_stat_database
- pg_stat_statements
- pg_extension
- pg_available_extensions
- pg_available_extension_versions
- pgsql基本原理
- 进程和内存结构
- 存储结构
- 数据文件的内部结构
- 垃圾回收机制VACUUM
- 事务日志WAL
- 并发控制
- 介绍
- 事务ID-txid
- 元组结构-Tuple Structure
- 事务状态记录-Commit Log (clog)
- 事务快照-Transaction Snapshot
- 事务快照实例
- 事务隔离
- 事务隔离级别
- 读已提交-Read committed
- 可重复读-Repeatable read
- 可序列化-Serializable
- 读未提交-Read uncommitted
- 锁机制
- 扩展机制解析
- 扩展的定义
- 扩展的安装方式
- 自定义创建扩展
- 扩展的管理
- 扩展使用实例
- 在pgsql中使用last、first聚合函数
- pgsql模糊查询不走索引的解决方案
- pgsql的pg_trgm扩展解析与验证
- 高可用
- LNMP
- LNMP环境搭建
- 一键安装包
- 搭建方法
- 配置文件目录
- 服务器管理系统
- 宝塔(Linux)
- 安装与使用
- 开放API
- 自定义apache日志
- 一键安装包LNMP1.5
- LNMP1.5:添加、删除站点
- LNMP1.5:php多版本切换
- LNMP1.5 部署 thinkphp项目
- Operation not permitted解决方法
- Nginx
- Nginx的产生
- 正向代理和反向代理
- 负载均衡
- Linux常用命令
- 目录与文件相关命令
- 目录操作命令
- 文件编辑命令
- 文件查看命令
- 文件查找命令
- 文件权限命令
- 文件上传下载命令
- 用户和群组相关命令
- 用户与用户组的关系
- 用户相关的系统配置文件
- 用户相关命令
- 用户组相关命令
- 压缩与解压相关命令
- .zip格式
- .tar.gz格式
- .gz格式
- .bz2格式
- 查看系统版本
- cpuinfo详解
- meminfo详解
- getconf获取系统信息
- 磁盘空间相关命令
- 查看系统负载情况
- 系统环境变量
- 网络相关命令
- ip命令详解
- ip命令格式详解
- ip address命令详解
- ip link命令详解
- ip rule命令详解
- ip route命令详解
- nslookup命令详解
- traceroute命令详解
- netstat命令详解
- route命令详解
- tcpdump命令详解
- 系统进程相关命令
- ps命令详解
- pstree命令详解
- kill命令详解
- 守护进程-supervisord
- 性能监控相关命令
- top命令详解
- iostat命令详解
- pidstat命令详解
- iotop命令详解
- mpstat命令详解
- vmstat命令详解
- ifstat命令详解
- sar命令详解
- iftop命令详解
- 定时任务相关命令
- ssh登录远程主机
- ssh口令登录
- ssh公钥登录
- ssh带密码登录
- ssh端口映射
- ssh配置文件
- ssh安全设置
- 历史纪录
- history命令详解
- linux开启操作日志记录
- 拓展
- git
- git初始化本地仓库-https
- git初始化仓库-ssh
- git-查看和设置config配置
- docker
- 概念
- docker原理
- docker镜像原理
- docker Overlay2 文件系统原理
- docker日志原理
- docker日志驱动
- docker容器日志管理
- 原理论证
- 验证容器的启动是作为Docker Daemon的子进程
- 验证syslog类型日志驱动
- 验证journald类型日志驱动
- 验证local类型日志驱动
- 修改容器的hostname
- 修改容器的hosts
- 验证联合挂载技术
- 验证启动多个容器对于磁盘的占用情况
- 验证写时复制原理
- 验证docker内容寻址原理
- docker存储目录
- /var/lib/docker目录
- image目录
- overlay2目录
- 数据卷
- 具名挂载和匿名挂载
- 数据卷容器
- Dockerfile详解
- dockerfile指令详解
- 实例:构造centos
- 实例:CMD和ENTRYPOINT的区别
- docker网络详解
- docker-compose
- 缓存
- redis
- redis的数据类型和应用场景
- redis持久化
- RDB持久化
- AOF持久化
- redis缓存穿透、缓存击穿、缓存雪崩
- 常见网络攻击类型
- CSRF攻击
- XSS攻击
- SQL注入
- Cookie攻击
- 历史项目经验
- 图片上传项目实例
- 原生php上传方法实例
- base64图片流
- tp5的上传方法封装实例
- 多级关系的递归查询
- 数组转树结构
- thinkphp5.1+ajax实现导出Excel
- JS 删除数组的某一项
- 判断是否为索引数组
- ip操作