Skip to content

Commit 3c9d398

Browse files
committed
Doc: improve index entry for "median".
We had an index entry for "median" attached to the percentile_cont function entry, which was pretty useless because a person following the link would never realize that that function was the one they were being hinted to use. Instead, make the index entry point at the example in syntax-aggregates, and add a <seealso> link to "percentile". Also, since that example explicitly claims to be calculating the median, make it use percentile_cont not percentile_disc. This makes no difference in terms of the larger goals of that section, but so far as I can find, nearly everyone thinks that "median" means the continuous not discrete calculation. Per gripe from Steven Winfield. Back-patch to 9.4 where we introduced percentile_cont. Discussion: https://postgr.es/m/[email protected]
1 parent ff33d14 commit 3c9d398

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

doc/src/sgml/func.sgml

-3
Original file line numberDiff line numberDiff line change
@@ -13774,9 +13774,6 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
1377413774
<primary>percentile</primary>
1377513775
<secondary>continuous</secondary>
1377613776
</indexterm>
13777-
<indexterm>
13778-
<primary>median</primary>
13779-
</indexterm>
1378013777
<function>percentile_cont(<replaceable class="parameter">fraction</replaceable>) WITHIN GROUP (ORDER BY <replaceable class="parameter">sort_expression</replaceable>)</function>
1378113778
</entry>
1378213779
<entry>

doc/src/sgml/syntax.sgml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1694,11 +1694,21 @@ SELECT string_agg(a ORDER BY a, ',') FROM table; -- incorrect
16941694
case, write just <literal>()</> not <literal>(*)</>.
16951695
(<productname>PostgreSQL</> will actually accept either spelling, but
16961696
only the first way conforms to the SQL standard.)
1697+
</para>
1698+
1699+
<para>
1700+
<indexterm>
1701+
<primary>median</primary>
1702+
</indexterm>
1703+
<indexterm>
1704+
<primary>median</primary>
1705+
<seealso>percentile</seealso>
1706+
</indexterm>
16971707
An example of an ordered-set aggregate call is:
16981708

16991709
<programlisting>
1700-
SELECT percentile_disc(0.5) WITHIN GROUP (ORDER BY income) FROM households;
1701-
percentile_disc
1710+
SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY income) FROM households;
1711+
percentile_cont
17021712
-----------------
17031713
50489
17041714
</programlisting>

0 commit comments

Comments
 (0)