title: Partition over or Group By best for Mysql
body: <pre><code>SELECT  P.FirstName, d.Name, EDH.StartDate
  FROM HumanResources.EmployeeDepartmentHistory edh INNER JOIN HumanResources.Department d
  ON EDH.DepartmentID=D.DepartmentID
  INNER JOIN HumanResources.Employee e
  ON EDH.BusinessEntityID=E.BusinessEntityID
  INNER JOIN Person.Person P
  ON E.BusinessEntityID=P.BusinessEntityID
  WHERE EndDate IS NULL 
  ORDER BY D.NAME;
  </code></pre>
  
  <p>I am trying to list the person in each department that has worked there the longest. I know that using the top(1) for each department would most likely be the best option but I can figure if using partition or group by is going to be the better option in this case. Anybody with more skill than me have any ideas?</p>