title: SQL Select sum and group by two columns
body: <p>I am trying to get a list of all music of the same <code>music_id</code> to have the SUM of price and that it was recorded on the same day</p>
  
  <p>Expected output:</p>
  
  <pre><code> music_id  | name | price | created          
  -----------+--------------+------------------------
   1222      | blue | 333   | 2015-07-07
   2222      | red  | 45    | 2016-07-07
   1222      | blue | 111   | 2017-07-07
  </code></pre>
  
  <p>I have a table that looks like this 'music'</p>
  
  <pre><code> music_id  | name | price | created_at           
  -----------+--------------+------------------------
   1222      | blue | 111   | 2015-07-07 22:42:39
   2222      | red  | 22.5  | 2016-07-07 22:42:39
   1222      | blue | 111   | 2017-07-07 22:42:39
   1222      | blue | 111   | 2015-07-07 11:42:39
   2222      | red  | 22.5  | 2016-07-07 11:42:39
   1222      | blue | 111   | 2015-07-07 11:42:39
  </code></pre>
  
  <p>this is my query:</p>
  
  <pre><code>SELECT music_id, name, SUM(price), TO_DATE(cast(created_at AS text), 'YYYY-MM-DD') AS created FROM music GROUP BY music_id, created;
  </code></pre>
  
  <p>but I will get an error, </p>
  
  <pre><code>ERROR:  column "music.name" must appear in the GROUP BY clause or be used in an   aggregate function 
  </code></pre>