title: Return the latest date based from a range of columns
body: <p>I have a query that counts the number of completed tasks as well as returning the original values.</p>
  <p>I'd like to add a new column which returns the most recent date (in this case <code>task_1_completed_date</code> or <code>task_2_completed_date</code> but in reality there are 20 task fields)</p>
  <pre><code>     (CASE WHEN task_1_completed_date IS NOT NULL THEN 1 ELSE 0 END +
          CASE WHEN task_2_completed_date IS NOT NULL THEN 1 ELSE 0 END
         ) AS task_completed_total 
  from (select JSON_EXTRACT_SCALAR(data, '$.task1.date') as task_1_completed_date
               JSON_EXTRACT_SCALAR(data, '$.task2.date') as task_2_completed_date
        from table
        WHERE pet_store = 'london'
       )
  </code></pre>
  <p>Not sure how to proceed, should I use a subquery here to order the task completion dates?</p>