title: Using SQL Find, Most Current Salary of each employee (note - One employee has many salary records on different dates)
body: <p>In my salaries table each employee has multiple salaries (one to many relationship) in various durations. These various durations are recorded within salaries table as columns &quot;from_date&quot; and &quot;to_date&quot;. Here's a snippet of salaries table:</p>
  <pre><code>Select * FROM salaries
  </code></pre>
  <p><a href="https://i.stack.imgur.com/WP34c.png" rel="nofollow noreferrer">Snippet of Salaries table</a></p>
  <p>How can I get an output that shows me a table that has employee number, from_date (based on most current salary date) and the most current salary. So basically I'm trying to answer - <strong>What is the most current salary of each employee?</strong></p>
  <p>I attempted and I could only get the employee number and the maximum from_date for each employee, but I am not able to pull most current salary, I have not put salary in the SELECT statement here because that will show me all the salaries of an employee, and, not the most current salary. Here's the code and the output I got:</p>
  <pre><code>SELECT emp_no, Max(from_date) as &quot;Most Current Salary Date&quot;
  from salaries
  group by emp_no
  </code></pre>
  <p><a href="https://i.stack.imgur.com/9Pty3.png" rel="nofollow noreferrer">Output of above code</a></p>
  <p><strong>End result I'm after is:</strong> In my output I want third column as salary column for each employee_no on the basis of their most current salary Max(from_date). Considering what I'm after in the output aggregating on salary column is not required.</p>