title: WP Query - Sort by start and end date but if end date null, they show at top
body: <p>We are trying to sort a list of events based on start year and end year but with the following condition.</p>
  <p>I have a list of events that have a start and end date (only year). There are some events where we do not have end date (NULL or EMPTY) which means they are ongoing events. What we want is to show all ongoing events first sorted by start date desc and then other events, again sorted by start date desc.</p>
  <p>For example if I have following events:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Event Name</th>
  <th>start year</th>
  <th>end year</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>event1</td>
  <td>2009</td>
  <td>null</td>
  </tr>
  <tr>
  <td>event2</td>
  <td>2010</td>
  <td>null</td>
  </tr>
  <tr>
  <td>event3</td>
  <td>2011</td>
  <td>2012</td>
  </tr>
  <tr>
  <td>event4</td>
  <td>2009</td>
  <td>2010</td>
  </tr>
  <tr>
  <td>event5</td>
  <td>2020</td>
  <td>null</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Expected Result:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th></th>
  <th></th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>event5</td>
  <td>2020</td>
  <td>null</td>
  </tr>
  <tr>
  <td>event2</td>
  <td>2010</td>
  <td>null</td>
  </tr>
  <tr>
  <td>event1</td>
  <td>2009</td>
  <td>null</td>
  </tr>
  <tr>
  <td>event3</td>
  <td>2011</td>
  <td>2012</td>
  </tr>
  <tr>
  <td>event4</td>
  <td>2009</td>
  <td>2010.</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Here is the code we tried but of course it's  not working:</p>
  <pre><code>$order = [
              'orderby' =&gt; 'meta_value',
              'order' =&gt; 'DESC',
              'meta_query' =&gt; array(
              'relation' =&gt; 'AND',
                  array(
                      'relation' =&gt; 'OR',
                          array( 
                              'key'=&gt;'start_year',
                              'compare' =&gt; 'EXISTS'           
                          ),
                          array( 
                              'key'=&gt;'start_year',
                              'compare' =&gt; 'NOT EXISTS'           
                          )
                      ),
                      array(
                          'key' =&gt; 'display_in_program',
                          'value' =&gt; 'Yes',
                          'compare' =&gt; '=',
                      )
                  ),
              ];
  </code></pre>
  <p>Any help would be appreciated.</p>