title: Simplify SQL query for me please
body: <ol>
  <li>I have a table of multiple employment records of an employee/s where i want to query for a certain range of date.</li>
  <li>Parameters are Company.id,date_hired,date_end</li>
  <li>Results must be on the range of the specified date and employee.id must only be one if the employee has multiple employment records result must get the latest employment record..</li>
  </ol>
  
  <p>THIS IS WHAT I CURRENTLY HAVE.</p>
  
  <pre><code>SELECT * 
    FROM employmentrecords 
   WHERE employmentrecords.id IN(
      SELECT MAX(employmentrecords.id) 
        FROM employmentrecords 
       WHERE ((employmentrecords.date_end &gt;='2017-08-22' 
          OR employmentrecords.date_end IS NULL 
          OR (employmentrecords.date_end &lt;='2017-08-22' 
          AND employmentrecords.date_end &gt;='2017-08-08')) 
          AND employmentrecords.date_hired &lt;='2017-08-22') 
       GROUP 
          BY employmentrecords.employee_id) 
         AND employmentrecords.company_id&lt;&gt;0`
  
  Hope any one would suggest a better approach.Thank you
  </code></pre>