title: How to assign a running value to a row depending on some conditions
body: <p>I'm trying to give a certain number of point to my row depending on some condition, I can't figure out how to write it.</p>
  <p>For a given Id, FormatCode and Price I want to give the value 1.
  For subsequent rows, for the same Id and Price, if the FormatCode is a multiple of a previous row with the same Id and price, I want to give the same value.</p>
  <p>For instance :</p>
  <p><code>00010405, 100, 0.3218 = 1</code></p>
  <p><code>00010405, 400, 0.3218 = 1</code> (400 % 100 = 0)</p>
  <p><code>00010405, 500, 0.3126 = 2</code> (500 % 100 = 0, but the price is different)</p>
  <p><code>00010405, 1000, 0.3126 = 2</code> (1000 % 500 and 1000 % 100 = 0, but the price of the format code 100 is different, hence it will take the value 2 because it has the same price)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Id</th>
  <th style="text-align: center;">Format Code</th>
  <th style="text-align: right;">Price</th>
  <th style="text-align: left;">Value</th>
  <th>Row</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">00010405</td>
  <td style="text-align: center;">100</td>
  <td style="text-align: right;">0.3218</td>
  <td style="text-align: left;">1</td>
  <td>1</td>
  </tr>
  <tr>
  <td style="text-align: center;">00010405</td>
  <td style="text-align: center;">400</td>
  <td style="text-align: right;">0.3218</td>
  <td style="text-align: left;">1</td>
  <td>2</td>
  </tr>
  <tr>
  <td style="text-align: center;">00010405</td>
  <td style="text-align: center;">500</td>
  <td style="text-align: right;">0.3126</td>
  <td style="text-align: left;">2</td>
  <td>3</td>
  </tr>
  <tr>
  <td style="text-align: center;">00010405</td>
  <td style="text-align: center;">1000</td>
  <td style="text-align: right;">0.3126</td>
  <td style="text-align: left;">2</td>
  <td>4</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>SELECT
     Id,
     FormatCode,
     Price,
     Value,
     ROW_NUMER() OVER (
        PARTITION BY Id
        ORDER BY FormatCode
     )
  FROM Table
  </code></pre>