@@ -23533,7 +23533,7 @@ SELECT count(*) FROM sometable;
23533
23533
</indexterm>
23534
23534
<function>lag</function> ( <parameter>value</parameter> <type>anycompatible</type>
23535
23535
<optional>, <parameter>offset</parameter> <type>integer</type>
23536
- <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> )
23536
+ <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> ) <optional> <parameter>null treatment</parameter> </optional>
23537
23537
<returnvalue>anycompatible</returnvalue>
23538
23538
</para>
23539
23539
<para>
@@ -23558,7 +23558,7 @@ SELECT count(*) FROM sometable;
23558
23558
</indexterm>
23559
23559
<function>lead</function> ( <parameter>value</parameter> <type>anycompatible</type>
23560
23560
<optional>, <parameter>offset</parameter> <type>integer</type>
23561
- <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> )
23561
+ <optional>, <parameter>default</parameter> <type>anycompatible</type> </optional></optional> ) <optional> <parameter>null treatment</parameter> </optional>
23562
23562
<returnvalue>anycompatible</returnvalue>
23563
23563
</para>
23564
23564
<para>
@@ -23581,7 +23581,7 @@ SELECT count(*) FROM sometable;
23581
23581
<indexterm>
23582
23582
<primary>first_value</primary>
23583
23583
</indexterm>
23584
- <function>first_value</function> ( <parameter>value</parameter> <type>anyelement</type> )
23584
+ <function>first_value</function> ( <parameter>value</parameter> <type>anyelement</type> ) <optional> <parameter>null treatment</parameter> </optional>
23585
23585
<returnvalue>anyelement</returnvalue>
23586
23586
</para>
23587
23587
<para>
@@ -23595,7 +23595,7 @@ SELECT count(*) FROM sometable;
23595
23595
<indexterm>
23596
23596
<primary>last_value</primary>
23597
23597
</indexterm>
23598
- <function>last_value</function> ( <parameter>value</parameter> <type>anyelement</type> )
23598
+ <function>last_value</function> ( <parameter>value</parameter> <type>anyelement</type> ) <optional> <parameter>null treatment</parameter> </optional>
23599
23599
<returnvalue>anyelement</returnvalue>
23600
23600
</para>
23601
23601
<para>
@@ -23609,7 +23609,7 @@ SELECT count(*) FROM sometable;
23609
23609
<indexterm>
23610
23610
<primary>nth_value</primary>
23611
23611
</indexterm>
23612
- <function>nth_value</function> ( <parameter>value</parameter> <type>anyelement</type>, <parameter>n</parameter> <type>integer</type> )
23612
+ <function>nth_value</function> ( <parameter>value</parameter> <type>anyelement</type>, <parameter>n</parameter> <type>integer</type> ) <optional> <parameter>null treatment</parameter> </optional>
23613
23613
<returnvalue>anyelement</returnvalue>
23614
23614
</para>
23615
23615
<para>
@@ -23658,18 +23658,26 @@ SELECT count(*) FROM sometable;
23658
23658
Other frame specifications can be used to obtain other effects.
23659
23659
</para>
23660
23660
23661
+ <para>
23662
+ The <literal>null treatment</literal> option must be one of:
23663
+ <synopsis>
23664
+ RESPECT NULLS
23665
+ IGNORE NULLS
23666
+ </synopsis>
23667
+ If unspecified, the default is <literal>RESPECT NULLS</literal> which includes NULL
23668
+ values in any result calculation. <literal>IGNORE NULLS</literal> ignores NULL values.
23669
+ This option is only allowed for the following functions: <function>lag</function>,
23670
+ <function>lead</function>, <function>first_value</function>, <function>last_value</function>,
23671
+ <function>nth_value</function>.
23672
+ </para>
23673
+
23661
23674
<note>
23662
23675
<para>
23663
- The SQL standard defines a <literal>RESPECT NULLS</literal> or
23664
- <literal>IGNORE NULLS</literal> option for <function>lead</function>, <function>lag</function>,
23665
- <function>first_value</function>, <function>last_value</function>, and
23666
- <function>nth_value</function>. This is not implemented in
23667
- <productname>PostgreSQL</productname>: the behavior is always the
23668
- same as the standard's default, namely <literal>RESPECT NULLS</literal>.
23669
- Likewise, the standard's <literal>FROM FIRST</literal> or <literal>FROM LAST</literal>
23670
- option for <function>nth_value</function> is not implemented: only the
23671
- default <literal>FROM FIRST</literal> behavior is supported. (You can achieve
23672
- the result of <literal>FROM LAST</literal> by reversing the <literal>ORDER BY</literal>
23676
+ The SQL standard defines a <literal>FROM FIRST</literal> or <literal>FROM LAST</literal>
23677
+ option for <function>nth_value</function>. This is not implemented in
23678
+ <productname>PostgreSQL</productname>: only the default <literal>FROM FIRST</literal>
23679
+ behavior is supported. (You can achieve the result of <literal>FROM LAST</literal> by
23680
+ reversing the <literal>ORDER BY</literal>
23673
23681
ordering.)
23674
23682
</para>
23675
23683
</note>
0 commit comments