title: How to display employee name column using group by clause
body: <p>Hello I have two tables <strong>Employee</strong> and <strong>Department</strong>. In employee I have empid,firstName, salary,Department_ID, in department i have deptid and deptname. I want to show the highest salaried employee name from each department with salary.
  I done with the following code </p>
  
  <pre><code>select  MAX(E.Salary),D.Name from Employee as E JOIN Department As D
  ON e.Department_ID = D.Department_ID
  GROUP BY D.Name
  </code></pre>
  
  <p>It is giving from only department table(i didn't include the E.FirstName here). When I write the query like below</p>
  
  <pre><code>select E.FirstName MAX(E.Salary),D.Name from Employee as E JOIN Department As D
  ON e.Department_ID = D.Department_ID
  GROUP BY D.Name
  </code></pre>
  
  <p>giving an error that </p>
  
  <blockquote>
    <p><strong>E.FirstName</strong>  is not contained in either an aggregate function or the GROUP BY
    clause.</p>
  </blockquote>
  
  <p>How to modify this to show employee name also?</p>
  
  <p>When I add the E.FirstName also in the group by clause I am getting following out put.</p>
  
  <blockquote>
    <h2>FirstName Salary DepartmentName</h2>
    
    <p>BAKER     1400.00 Operations</p>
    
    <p>Allen      5400.00    Research</p>
    
    <p>Smith      1800.00    Research</p>
    
    <p>Dennis     4500.00    Sales</p>
    
    <p>Mihir      7500.00    Sales</p>
    
    <p>WARK       8000.00    Sales</p>
  </blockquote>
  
  <p>I want to display only Max salaried employees with their departments and salaries.</p>