title: Oracle ranking with condition
body: <p>I am currently trying to rank my results based on a custom condition. Let us assume that my data looks like the following:</p>
  
  <pre><code>col1   col2    col3     
  -----------------------
  1       1       2       
  1       3       33   
  2       4       5   
  3       6       40  
  1       2       5
  3       5       10 
  </code></pre>
  
  <p>I now want to group by col1 and order by col2 and then rank the results. However, I only want to increase the rank if col3 is larger than 30. So the results should look like:</p>
  
  <pre><code>col1   col2    col3    rank     
  -----------------------------
  1       1       2       1   
  1       2       5       1
  1       3       33      2  
  2       4       5       1 
  3       5       10      1 
  3       6       40      2
  </code></pre>
  
  <p>I just can't find an elegant solution to the problem. If I just use classic ranking, the whole thing does not work of course; e.g.:</p>
  
  <p><code>RANK() OVER (PARTITION BY col1 ORDER BY col2)</code></p>
  
  <p>If possible, I would like to work with window functions here due to performance issues. I also work in Google's Bigquery environment.</p>