Using group by in mysql, cause error 1055
<p><a href="https://i.stack.imgur.com/F7rRk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F7rRk.png" alt="enter image description here"></a></p>

<p>when I'm trying to use mysql to select the first form into the second form</p>

<pre><code>select id, name ,
(case when years=1992 then cost else 0 end) as year1992,
(case when years=1993 then cost else 0 end) as year1993,
(case when years=1994 then cost else 0 end) as year1994
from pivot 
group by name;
</code></pre>

<p>I got a strange error</p>

<blockquote>
  <p>ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'nctest.pivot.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by</p>
</blockquote>

<p>What's the problem here?</p>

<p>-------------update--------------------------</p>

<p>I find I make a mistake using the group by.</p>

<pre><code>select id, name ,
sum(case when years=1992 then cost else 0 end) as year1992,
sum(case when years=1993 then cost else 0 end) as year1993,
sum(case when years=1994 then cost else 0 end) as year1994
from pivot 
group by id, name;
</code></pre>

<p>then it works;;</p>