title: MySQL - Selecting a Column not in Group By
body: <p>I'm trying to add features to a preexisting application and I came across a MySQL view something like this:</p>
  
  <pre><code>SELECT
       AVG(table_name.col1),
       AVG(table_name.col2),
       AVG(table_name.col3),
       table_name.personID,
       table_name.col4
  FROM table_name
  GROUP BY table_name.personID;
  </code></pre>
  
  <p>OK so there's a few aggregate functions.  You can select personID because you're grouping by it.  But it also is selecting a column that is not in an aggregate function and is not a part of the GROUP BY clause.  How is this possible???  Does it just pick a random value because the values definitely aren't unique per group?</p>
  
  <p>Where I come from (MSSQL Server), that's an error.  Can someone explain this behavior to me and why it's allowed in MySQL?</p>