title: Alternatives to sliding window frames with RANGE on snowflake
body: <p>I'm migrate some BigQuery code to snowflake, and I'm having a little trouble to using Window function with range. This is because on Snowflake range sliding window frames is not supported.
  I need to use &quot;RANGE BETWEEN 2 PRECEDING AND CURRENT ROW&quot; logic
  any thoughts on how we can replicate this logic on snowflake?</p>
  <pre><code>WITH base AS (
    SELECT * FROM (
      SELECT 7 AS num
      UNION ALL SELECT 2 AS num
      UNION ALL SELECT 2 AS num
      UNION ALL SELECT 5 AS num
      UNION ALL SELECT 3 AS num
      UNION ALL SELECT 7 AS num
      UNION ALL SELECT 7 AS num
  ))
  SELECT
  num,
  COUNT(*) OVER (ORDER BY num ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS row_count,
  COUNT(*) OVER (ORDER BY num RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS range_count,
  SUM(num) OVER (ORDER BY num ROWS BETWEEN 2 PRECEDING AND CURRENT ROW) AS row_sum,
  SUM(num) OVER (ORDER BY num RANGE BETWEEN 2 PRECEDING AND CURRENT ROW) AS range_sum
  FROM base
  ORDER BY num
  </code></pre>
  <p>Expecting result:<a href="https://i.stack.imgur.com/VSRVL.png" rel="nofollow noreferrer">enter image description here</a></p>