<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Window clauses</title>
    <link>/en/sql-reference/language-elements/window-clauses/</link>
    <description>Recent content in Window clauses on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/sql-reference/language-elements/window-clauses/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Sql-Reference: Window partition clause</title>
      <link>/en/sql-reference/language-elements/window-clauses/window-partition-clause/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/language-elements/window-clauses/window-partition-clause/</guid>
      <description>
        
        
        &lt;p&gt;When specified, a window partition clause divides the rows of the function input based on user-provided expressions. If no expression is provided, the partition clause can improve query performance by using parallelism. If you do not specify a window partition clause, all input rows are treated as a single partition.&lt;/p&gt;
&lt;p&gt;Window partitioning is similar to the GROUP BY clause. However, PARTITION BEST and PARTITION NODES may only be used with analytic functions and return only one result per input row, while PARTITION ROW and PARTITION LEFT JOIN can be used for single-phase transform functions and return multiple values per input row.&lt;/p&gt;
&lt;p&gt;When used with analytic functions, results are computed per partition and start over again (reset) at the beginning of each subsequent partition.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{ PARTITION BY &lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt;[,...] 
  | PARTITION BEST 
  | PARTITION NODES 
  | PARTITION ROW 
  | PARTITION LEFT JOIN }
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;PARTITION BY &lt;/code&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;Expression on which to sort the partition, where &lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt; can be a column, constant, or an arbitrary expression formed on columns. Use &lt;code&gt;PARTITION BY&lt;/code&gt; for functions with specific partitioning requirements.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;PARTITION BEST&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Use parallelism to improve performance for multi-threaded queries across multiple nodes.
&lt;p&gt;&lt;code&gt;OVER(PARTITION BEST)&lt;/code&gt; provides the best performance on multi-threaded queries across multiple nodes.&lt;/p&gt;
&lt;p&gt;The following considerations apply to using &lt;code&gt;PARTITION BEST&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use &lt;code&gt;PARTITION BEST&lt;/code&gt; for analytic functions that have no partitioning requirements and are thread safe—for example, a one-to-many transform.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Do not use &lt;code&gt;PARTITION BEST&lt;/code&gt; on user-defined transform functions (UDTFs) that are not thread-safe. Doing so can produce an error or incorrect results. If a UDTF is not thread safe, use &lt;code&gt;PARTITION NODES&lt;/code&gt; .&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;PARTITION NODES&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Use parallelism to improve performance for single-threaded queries across multiple nodes.
&lt;p&gt;&lt;code&gt;OVER(PARTITION NODES)&lt;/code&gt; provides the best performance on single-threaded queries across multiple nodes.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;PARTITION ROW&lt;/code&gt;, &lt;code&gt;PARTITION LEFT JOIN&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Use to feed input partitions of exactly one row. If used, any arbitrary expression may be used in the query target list alongside the UDTF. PARTITION LEFT JOIN returns a row of NULLs if an input row would otherwise produce no output.
&lt;p&gt;May not be used for analytic functions or multi-phase transform functions. Note that only one PARTITION ROW transform function is allowed in the target list for each level of the query.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-partitioning/#&#34;&gt;Window partitioning&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: Window order clause</title>
      <link>/en/sql-reference/language-elements/window-clauses/window-order-clause/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/language-elements/window-clauses/window-order-clause/</guid>
      <description>
        
        
        &lt;p&gt;Specifies how to sort rows that are supplied to an analytic function. If the OVER clause also includes a &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-partition-clause/&#34;&gt;window partition clause&lt;/a&gt;, rows are sorted within each partition.&lt;/p&gt;
&lt;p&gt;The window order clause only specifies order within a window result set. The query can have its own &lt;a href=&#34;../../../../en/sql-reference/statements/select/order-by-clause/&#34;&gt;ORDER BY&lt;/a&gt; clause outside the OVER clause. This has precedence over the window order clause and orders the final result set.&lt;/p&gt;
&lt;p&gt;A window order clause also creates a default &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-frame-clause/&#34;&gt;window frame&lt;/a&gt; if none is explicitly specified.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ORDER BY { &lt;span class=&#34;code-variable&#34;&gt;expression&lt;/span&gt; [ ASC | DESC [ NULLS { FIRST | LAST | AUTO } ] ]
  }[,...]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;expression&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A column, constant, or arbitrary expression formed on columns on which to sort input rows.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;ASC | DESC&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Sort order: ascending (default) or descending.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;NULLS {FIRST | LAST | AUTO}&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;How to position nulls. &lt;code&gt;NULLS AUTO&lt;/code&gt; means to choose the positioning that is most efficient for this query.
&lt;p&gt;&lt;code&gt;ASC&lt;/code&gt; defaults to &lt;code&gt;NULLS LAST&lt;/code&gt; and &lt;code&gt;DESC&lt;/code&gt; defaults to &lt;code&gt;NULLS FIRST&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you omit all sort qualifiers, OpenText™ Analytics Database uses &lt;code&gt;ASC NULLS LAST&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For more information, see &lt;a href=&#34;../../../../en/data-analysis/query-optimization/analytic-functions/null-sort-order/#&#34;&gt;NULL sort order&lt;/a&gt; and &lt;a href=&#34;../../../../en/data-analysis/query-optimization/analytic-functions/runtime-sorting-of-null-values-analytic-functions/#&#34;&gt;Runtime sorting of NULL values in analytic functions&lt;/a&gt;.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-ordering/#&#34;&gt;Window ordering&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: Window frame clause</title>
      <link>/en/sql-reference/language-elements/window-clauses/window-frame-clause/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/language-elements/window-clauses/window-frame-clause/</guid>
      <description>
        
        
        &lt;p&gt;Specifies a window frame, which comprises a set of rows relative to the row that is currently being evaluated by an analytic function. After the function processes that row and its window, OpenText™ Analytics Database advances the current row and adjusts the window boundaries accordingly. If the OVER clause also specifies a &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-partition-clause/&#34;&gt;partition&lt;/a&gt;, the database also checks that window boundaries do not cross partition boundaries. This process repeats until the function evaluates the last row of the last partition.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{ ROWS | RANGE } { BETWEEN &lt;span class=&#34;code-variable&#34;&gt;start-point&lt;/span&gt; AND &lt;span class=&#34;code-variable&#34;&gt;end-point&lt;/span&gt; } | &lt;span class=&#34;code-variable&#34;&gt;start-point&lt;/span&gt;

&lt;span class=&#34;code-variable&#34;&gt;start-point&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;end-point&lt;/span&gt;:

  { UNBOUNDED {PRECEDING | FOLLOWING}
    | CURRENT ROW
    | &lt;span class=&#34;code-variable&#34;&gt;constant-value&lt;/span&gt;  {PRECEDING | FOLLOWING}}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;ROWS | RANGE&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Whether to interpret window frame dimensions as physical (&lt;code&gt;ROWS&lt;/code&gt;) or logical (&lt;code&gt;RANGE&lt;/code&gt;) offsets from the current row. See &lt;a href=&#34;#ROWSversusRANGE&#34;&gt;ROWS versus RANGE&lt;/a&gt; below for details.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;BETWEEN &lt;/code&gt;&lt;em&gt;&lt;code&gt;start-point &lt;/code&gt;&lt;/em&gt;&lt;code&gt;AND&lt;/code&gt;&lt;em&gt;&lt;code&gt; end-point&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;First and last rows of the window, where &lt;em&gt;&lt;code&gt;start-point&lt;/code&gt;&lt;/em&gt; and &lt;em&gt;&lt;code&gt;end-point&lt;/code&gt;&lt;/em&gt; can be one of the following:
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;UNBOUNDED {PRECEDING | FOLLOWING}&lt;/code&gt;: The current partition&#39;s first (&lt;code&gt;PRECEDING&lt;/code&gt;) or last (&lt;code&gt;FOLLOWING&lt;/code&gt;) row.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;CURRENT ROW&lt;/code&gt;: The current row or value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;&lt;code&gt;constant-value&lt;/code&gt;&lt;/em&gt; &lt;code&gt;{PRECEDING | FOLLOWING}&lt;/code&gt;: A constant value or expression that evaluates to a constant value. This value is interpreted as either a physical or logical offset from the current row, depending on whether you use ROWS or RANGE. See &lt;a href=&#34;#ROWSversusRANGE&#34;&gt;ROWS versus RANGE&lt;/a&gt; for other restrictions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;&lt;code&gt;start-point&lt;/code&gt;&lt;/em&gt; must resolve to a row or value that is less than or equal to &lt;em&gt;&lt;code&gt;end-point&lt;/code&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;em&gt;&lt;code&gt;start-point&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;If &lt;code&gt;ROWS&lt;/code&gt; or &lt;code&gt;RANGE&lt;/code&gt; specifies only a start point, the database uses the current row as the end point and creates the window frame accordingly. In this case, &lt;em&gt;&lt;code&gt;start-point&lt;/code&gt;&lt;/em&gt; must resolve to a row that is less than or equal to the current row.&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;p&gt;In order to specify a window frame, the &lt;code&gt;OVER&lt;/code&gt; must also specify a &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-order-clause/&#34;&gt;window order (ORDER BY) clause&lt;/a&gt;. If the OVER clause omits specifying a window frame, the function creates a default window that extends from the current row to the first row in the current partition. This is equivalent to the following clause:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;RANGE UNBOUNDED PRECEDING AND CURRENT ROW
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a name=&#34;ROWSversusRANGE&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;rows-versus-range&#34;&gt;ROWS versus RANGE&lt;/h2&gt;
&lt;p&gt;The window frame&#39;s offset from the current row can be physical or logical:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;ROWS&lt;/code&gt; (physical): the start and end points are relative to the current row. If either is a constant value, it must evaluate to a positive integer.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;RANGE&lt;/code&gt; (logical): the start and end points represent a logical offset, such as time. The range value must match the &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-order-clause/&#34;&gt;window order (ORDER BY) clause&lt;/a&gt; data type: NUMERIC, DATE/TIME, FLOAT or INTEGER.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When setting constant values for &lt;code&gt;ROWS&lt;/code&gt;, the constant must evaluate to a positive INTEGER.&lt;/p&gt;
&lt;p&gt;When setting constant values for &lt;code&gt;RANGE&lt;/code&gt;, the following requirements apply:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The constant must evaluate to a positive numeric value or INTERVAL literal.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the constant evaluates to a NUMERIC value, the ORDER BY column type must be a NUMERIC data type.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the constant evaluates to an INTERVAL DAY TO SECOND subtype, the ORDER BY column type must be one of the following: TIMESTAMP, TIME, DATE, or INTERVAL DAY TO SECOND.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If the constant evaluates to an INTERVAL YEAR TO MONTH, the ORDER BY column type must be one of the following: TIMESTAMP, DATE, or INTERVAL YEAR TO MONTH.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-order-clause/&#34;&gt;window order clause&lt;/a&gt; can specify only one expression.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-framing/#&#34;&gt;Window framing&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Sql-Reference: Window name clause</title>
      <link>/en/sql-reference/language-elements/window-clauses/window-name-clause/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/sql-reference/language-elements/window-clauses/window-name-clause/</guid>
      <description>
        
        
        &lt;p&gt;Defines a named window that specifies window partition and order clauses for an analytic function. This window is specified in the function&#39;s &lt;code&gt;OVER&lt;/code&gt; clause. Named windows can be useful when you write queries that invoke multiple analytic functions with similar &lt;code&gt;OVER&lt;/code&gt; clauses, such as functions that use the same partition (&lt;code&gt;PARTITION BY&lt;/code&gt;) clauses.&lt;/p&gt;
&lt;h2 id=&#34;syntax&#34;&gt;Syntax&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;WINDOW &lt;span class=&#34;code-variable&#34;&gt;window-name&lt;/span&gt; AS ( &lt;span class=&#34;code-variable&#34;&gt;window-partition-clause&lt;/span&gt; [&lt;span class=&#34;code-variable&#34;&gt;window-order-clause&lt;/span&gt;] )
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;WINDOW &lt;/code&gt;&lt;em&gt;&lt;code&gt;window-name&lt;/code&gt;&lt;/em&gt;&lt;/dt&gt;
&lt;dd&gt;A window name that is unique within the same query.&lt;/dd&gt;
&lt;dt&gt;
&lt;code&gt;&lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-partition-clause/#&#34;&gt;window-partition-clause&lt;/a&gt;&lt;/span&gt; [&lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-order-clause/#&#34;&gt;window-order-clause&lt;/a&gt;&lt;/span&gt;]&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;
&lt;p&gt;Clauses to invoke when an &lt;code&gt;OVER&lt;/code&gt; clause references this window.&lt;/p&gt;
&lt;p&gt;If the window definition omits a &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-order-clause/&#34;&gt;window order clause&lt;/a&gt;, the &lt;code&gt;OVER&lt;/code&gt; clause can specify its own order clause.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A &lt;code&gt;WINDOW&lt;/code&gt; clause cannot include a &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/window-framing/&#34;&gt;window frame clause&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Each &lt;code&gt;WINDOW&lt;/code&gt; clause within the same query must have a unique name.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A &lt;code&gt;WINDOW&lt;/code&gt; clause can reference another window that is already named. For example, the following query names window &lt;code&gt;w1&lt;/code&gt; before &lt;code&gt;w2&lt;/code&gt;. Thus, the &lt;code&gt;WINDOW&lt;/code&gt; clause that defines &lt;code&gt;w2&lt;/code&gt; can reference &lt;code&gt;w1&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT RANK() OVER(w1 ORDER BY sal DESC), RANK() OVER w2
   FROM EMP WINDOW w1 AS (PARTITION BY deptno), w2 AS (w1 ORDER BY sal);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;See &lt;a href=&#34;../../../../en/data-analysis/sql-analytics/named-windows/#&#34;&gt;Named windows&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;a href=&#34;../../../../en/sql-reference/functions/analytic-functions/#&#34;&gt;Analytic functions&lt;/a&gt;

      </description>
    </item>
    
  </channel>
</rss>
