title: How to set sliding windows frame to range BETWEEN 1 Following AND UNBOUNDED Following in snowflake
body: <p>I need to convert oracle sql to snowflake sql.</p>
  
  <p>In oracle, I have this :</p>
  
  <pre><code>last_value(my_table.my_col) 
  Over(Partition BY 
  my_table.my_col2,
  my_table.my_col3
  Order By my_table.my_col4 
  range BETWEEN 1 Following AND UNBOUNDED Following)
  </code></pre>
  
  <p>In snowflake as written in the documentation
  <a href="https://docs.snowflake.com/en/user-guide/functions-window-using.html" rel="nofollow noreferrer">https://docs.snowflake.com/en/user-guide/functions-window-using.html</a>
  <a href="https://docs.snowflake.com/en/sql-reference/functions-analytic.html" rel="nofollow noreferrer">https://docs.snowflake.com/en/sql-reference/functions-analytic.html</a></p>
  
  <p>For sliding frame, range is not supported and I have to use rows</p>
  
  <p>So I have to use this :</p>
  
  <pre><code>slidingFrame ::=
  {
     ROWS BETWEEN &lt;N&gt; { PRECEDING | FOLLOWING } AND &lt;N&gt; { PRECEDING | FOLLOWING }
   | ROWS BETWEEN UNBOUNDED PRECEDING AND &lt;N&gt; { PRECEDING | FOLLOWING }
   | ROWS BETWEEN &lt;N&gt; { PRECEDING | FOLLOWING } AND UNBOUNDED FOLLOWING
  }
  </code></pre>
  
  <p>So I should be using this</p>
  
  <pre><code>last_value(my_table.my_col) 
  Over(Partition BY 
  my_table.my_col2,
  my_table.my_col3
  Order By my_table.my_col4 
  rows BETWEEN 1 Following AND UNBOUNDED Following)
  </code></pre>
  
  <p>But it throws the error : "Invalid Window Frame"</p>
  
  <p>Note : </p>
  
  <p>I can do </p>
  
  <pre><code>last_value(my_table.my_col) 
  Over(Partition BY 
  my_table.my_col2,
  my_table.my_col3
  Order By my_table.my_col4 
  rows BETWEEN CURRENT row AND UNBOUNDED Following)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>last_value(my_table.my_col) 
  Over(Partition BY 
  my_table.my_col2,
  my_table.my_col3
  Order By my_table.my_col4 
  rows BETWEEN 1 PRECEDING AND UNBOUNDED Following)
  </code></pre>
  
  <p>without error</p>
  
  <p>But I need the <code>1 following</code> to get the same result.</p>
  
  <p>Do you have any idea what's going on here ?</p>
  
  <p>Thanks</p>