title: Maximum per partition
body: <p>Tell me how to correctly compose a query so that the following records are displayed, as in the example.
  I have a partition by id_1 and id_2 and I only take entries with the maximum operdate.</p>
  <pre><code>select a.* 
  from (select t1.*,
         rank() over (partition by id_1,id_2 order by operdate desc) rn
        from table1 t1)
  where a.rn=1
  </code></pre>
  <p>And I need to display the maximum end_circulation in the partition for these records. I understand how to do it.</p>
  <pre><code>select a.*
  from (select t1.*,
         rank() over (partition by id_1,id_2 order by operdate desc) rn,
         max(end_circulation) over(partition by id_1,id_2) max_end_circulation
        from table1 t1)
  where a.rn=1
  </code></pre>
  <p>But I need that if there is at least one NULL in end_circulation, then NULL is also set in max_end_circulation. How to do it right?</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id_1</th>
  <th>id_2</th>
  <th>end_circulation</th>
  <th>operdate</th>
  <th>rn</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2123</td>
  <td>6</td>
  <td>2021-06-07 00:00:00</td>
  <td>2021-03-04</td>
  <td>1</td>
  </tr>
  <tr>
  <td>2123</td>
  <td>6</td>
  <td>2021-05-05 00:00:00</td>
  <td>2021-02-01</td>
  <td>2</td>
  </tr>
  <tr>
  <td>3222</td>
  <td>3</td>
  <td>2021-06-07 00:00:00</td>
  <td>2021-01-01</td>
  <td>1</td>
  </tr>
  <tr>
  <td>3222</td>
  <td>3</td>
  <td>NULL</td>
  <td>2020-12-11</td>
  <td>2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>RESULT:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id_1</th>
  <th>id_2</th>
  <th>end_circulation</th>
  <th>operdate</th>
  <th>rn</th>
  <th>max_end_circulation</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2123</td>
  <td>6</td>
  <td>2021-06-07 00:00:00</td>
  <td>2021-03-04</td>
  <td>1</td>
  <td>2021-06-07 00:00:00</td>
  </tr>
  <tr>
  <td>3222</td>
  <td>3</td>
  <td>2021-06-07 00:00:00</td>
  <td>2021-01-01</td>
  <td>1</td>
  <td>NULL</td>
  </tr>
  </tbody>
  </table>
  </div>