title: SQL: Must appear in the GROUP BY clause or be used in an aggregate function
body: <p>I have a Table that displays a teams salaries and I want to display their minimum, maximum and average salary for each team for each year. </p>
  
  <p>My table looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/0dqRH.png" alt="Table description"></p>
  
  <p>I run the following SQL:</p>
  
  <pre><code>SELECT MIN(salary), MAX(salary), AVG(salary), teamID, yearID FROM salaries; 
  </code></pre>
  
  <p>But get the following error:</p>
  
  <blockquote>
    <p>ERROR: column "salaries.teamid" must appear in the GROUP BY clause or be used in an aggregate function</p>
  </blockquote>
  
  <p>What does it mean?</p>