Oracle - Update rows with a min value in the group of a column from another table
<p>I am facing this scenario: Table Employee has joining_date column. Table Booking has booking_date column and a foreign key (employee_id) to Employee. Employee has some NULL values in its joining_date column. I want to fill them with the FIRST booking_date value of those employees. How can I do?</p>

<p>FYI:
I can query with complex join statements to extract the first booking_date of employees whose joining_date is NULL as below:</p>

<pre><code>SELECT emp.employee_id, emp.joining_date, temp2.booking_date FROM employee emp
  LEFT JOIN (SELECT bo.employee_id, bo.booking_date FROM booking bo
    INNER JOIN (SELECT employee_id, MIN(booking_date) mindate FROM booking GROUP BY employee_id) temp1
    ON bo.employee_id = temp1.employee_id AND bo.booking_date = temp1.mindate) temp2
  ON emp.employee_id = temp2.employee_id
WHERE emp.joining_date IS NULL;
</code></pre>

<p>But I'm struggling with putting this complex select into the update statement:</p>

<pre><code>UPDATE employee emp
SET emp.joining_date = (SELECT ...)
WHERE emp.joining_date IS NULL;
</code></pre>