title: SQL: is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
body: <pre><code>left join
       (
       SELECT my_number, MAX(id) as id
       FROM table1
       GROUP BY location 
       ) newNum
       on newNum.Part = c.OtherPart
  
  left join table2 t2 on t2.id = newNum.id and t2.site = a.site
  </code></pre>
  
  <p>Situation: I have the data fields (among others) my_number, location, and id in table1. In table2 I have the data fields (among others) id, site, date. I am joining those to other views/tables (c and a) that have some of the same data fields and my_numbers.</p>
  
  <p>My goal: Each my_number has multiple id's and I want the greatest id value for each site. That is why I used group by site. 
  Then I need to get the 'date' of the my_number based on the id, because the second table does not contain the my_number, just its associated id. 
  There are a total of 3 sites, so I need the 3 greatest id value for each site. Then I want to get the 'date' of those 3 id values</p>
  
  <p>Output table ex:</p>
  
  <pre><code>a.num   a.site  a.date  c.OtherPart T2.date
  15            TN    1.1.16        17    3.19.16
  15            FL    2.21.16       17    4.22.16
  15            TX    1.7.15        17    3.21.16
  </code></pre>