title: LAG and LEAD based on parameter
body: <p>I have table - Invoices, with such structure:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">Id</th>
  <th style="text-align: center;">InvoiceNo</th>
  <th style="text-align: center;">Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">10</td>
  <td style="text-align: center;">11-12-21</td>
  </tr>
  <tr>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">20</td>
  <td style="text-align: center;">12-12-21</td>
  </tr>
  <tr>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">30</td>
  <td style="text-align: center;">13-12-21</td>
  </tr>
  <tr>
  <td style="text-align: center;">4</td>
  <td style="text-align: center;">40</td>
  <td style="text-align: center;">NULL</td>
  </tr>
  <tr>
  <td style="text-align: center;">5</td>
  <td style="text-align: center;">50</td>
  <td style="text-align: center;">14-12-21</td>
  </tr>
  <tr>
  <td style="text-align: center;">6</td>
  <td style="text-align: center;">60</td>
  <td style="text-align: center;">NULL</td>
  </tr>
  <tr>
  <td style="text-align: center;">7</td>
  <td style="text-align: center;">70</td>
  <td style="text-align: center;">NULL</td>
  </tr>
  <tr>
  <td style="text-align: center;">8</td>
  <td style="text-align: center;">80</td>
  <td style="text-align: center;">15-12-21</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I need to do - I need to find InvoiceNo's, the date field of the next or previous line of which contains null.
  So, based on provided data - I should receive:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">InvoiceNo</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">30</td>
  </tr>
  <tr>
  <td style="text-align: center;">50</td>
  </tr>
  <tr>
  <td style="text-align: center;">80</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>But how to do this? One option that I found - <code>LAG()</code> and <code>LEAD()</code> functions, and with these functions I can receive numbers and dates, but cannot use parameters - so cannot provide &quot;Date is not null&quot; check.</p>