title: ROWS BETWEEN CURRENT ROW PRECEDING AND EXACT MATCH FOLLOWING
body: <p>considering the following dummy dataset</p>
  
  <pre><code>ID EVENT VALUE SORT_KEY
  1 submitted 10 1
  1 action 20 2
  1 closed 30 3
  1 action 30 4
  2 submitted 10 1 
  2 action 10 2
  2 action 10 3
  2 closed 10 4
  2 action 10 5
  3 action 29 1
  3 submitted 20 2
  3 action 10 3
  3 closed 10 4
  3 action 10 5
  4 action 10 1
  </code></pre>
  
  <p>I want to sum all actions per id between submitted (included) and closed. I don't care about events outside these boundaries.
  I wonder if it is possible to build a window function partitioning by the id and following until a match expression. </p>
  
  <p>Desired result:</p>
  
  <pre><code>ID EVENT VALUE_SUM
  1 submitted 60
  2 submitted 40
  3 submitted 40
  </code></pre>
  
  <p>A query calculating this would look like something like the following:</p>
  
  <pre><code>SELECT 
      id
    , event
    , SUM(value) OVER (PARTITION BY id ROWS BETWEEN CURRENT ROW PRECEDING AND event='closed' FOLLOWING) as value_sum
  FROM my_table
  WHERE event = 'submitted'
  </code></pre>
  
  <p>I am aware that it is maybe possible to do this with multiple joins with itself, but due to the size of the data, and optimisation reason I wonder if it is possible to do this with a window function. Thanks.</p>