title: SQL finding no activity between dates
body: <p>I am trying to find how many days that the company from EmployeeActivity Table using Postgres did not have any activity of an joining an employee or cutting employees. Null refer to they who still do activity inside the company meanwhile DateLeave refer to them leaving the company or not working anymore. </p>
  
  <pre><code>DateJoined   DateLeave     Name
  ................................
  2012-06-20   NULL          Terrence
  2012-06-21   2013-06-23    Mady
  2010-06-20   2012-06-24    Greg
  2013-06-20   NULL          Matt
  </code></pre>
  
  <p>my trials for this was</p>
  
  <pre><code>select EXTRACT(DAY FROM MAX(EmployeeActivity.DateJoined) - MIN(EmployeeActivity.DateLeave) 
  
  From EmployeeActivity
  
  WHERE EmployeeActivity.DateLeave IS 'NULL'
  </code></pre>
  
  <p>However it shows wrong value, especially for longer table</p>
  
  <p>Output Expectation: 
  My expectation for this output is to query the longest period of days that the company have no activity in assigning or firing Employee.</p>